logo

Flower Power for Android

... an open source library for Parrot's Flower Power sensor platform. It is 100% pure Java.

Class Diagram

This class digram depicts the most important classes to be used by developers.

As you can see, there are 3 interfaces (IFlowerPowerSensor, IFlowerPowerServiceManager, IFlowerPowerServiceListener) with which a client application interacts as well as 2 classes realizing the data model (FlowerPower, FlowerPowerMetadata). All of the other classes are hidden for the developer and are only of interest to those wanting to extend the library itself.

IFlowerPowerServiceManager: This class handles the management of individual flower power instances. You mainly use it to bind (and unbind) the communication service and to connect (and disconnect) a flower power sensor. It provides method which must be called upon specific lifecycle stages of your application (see Lifecycle). Moreover, you need to register your application as an IFlowerPowerServiceListener with the manager. As such a listener, you'll receive lifecycle events, such as when the communication service is ready (or not), when the flower power sensor is connected (or disconnects) and most importantly when data is available. In order to receive such events, your application needs provide implementations for all those methods (see the example, that ships with the distribution).

Once a Flower Power sensor is connected, you probably want to read some values or be notified periodically about updated values. The IFlowerPowerSensor is the be used for that. It provides methods for triggering reads of all kinds of values and for enabling (and disabling) notifications (i.e. periodic reads). Note: all these methods return noting, because reads and notifications are executed asynchronously. Once a result is available, it is passed via the IFlowerPowerListener callback (see above) to your application.

This dataAvailable callback carries an instance of the FlowerPower data model. This data model provides methods to access all sensor readings as well as timestamps. Note: the model is reused throughout the whole service lifetime, so if e.g. you read the sensor's friendly name once, you do not need to read it again, because it is still set in the Flower Power instance.

Finally, the FlowerPowerService realizes most of the Bluetooth LE handling. It connects via Bluetooth to your Flower Power, it offers methods to read characteristics and to handle notifications. Internally, it is realized as a job queue, so commands are executed sequentially in order not to overwrite previously issues commands. But these internals are only of interest to those who want to work on the library's internals.

News


28.04.2014 First public release.

 

 

Documentation


Tutorial (soon to come)
FAQ (nothing asked yet)
Class Diagram
Lifecycle