-
Notifications
You must be signed in to change notification settings - Fork 1
Metaphors and buzz
This tutorial is intended to explain basic concepts of SensorLib and example ForaApp demonstrating how to use the library.
Code is best documentation. However, you might be interested in the metaphors first.
Driver is an Android Service build according to Remote Messenger Service Sample .
Client is an Activity, Fragments or other Service which registers to exchange Messages with the Driver. Clients of the Driver are identified with a String clientId (e.x. client's Activity classpath).
Messages sent by Driver can be persisted, so that if client is stopped or destroyed, it would still receive a pending Message the next time it registers with Driver.
Driver implements following high-level functionality:
- register a client
- register a clients out
- stop execution after on receiving a message
- automatically stop execution if idle
Sensor Sink is much more capable than just DriverService. It can:
- connect to a Bluetooth HOST device
- tell about it's connection status (connected, connecting, disconnected)
- disconnect
- tell the number of records
- send records from specific range filtered by type
Driver Connection have following states:
- bound
- unbound
Sensor Sink Connection is a Driver Connection. It implements the interface of (surprise, surprise) Sink Sensor. It has following states additionally to ones of Driver Connection:
- counting
- downloading
In order to enable background data connection, both Driver and Sensor Sink can work as Started Service or Bound Service. Choose based on your needs, but mind this short advice:
- If you want to collect data on the background, use Started Service and start it in Application.onCreate .
- If you only need to receive/send data, while application is actively used, Bind in Activity.onCreate and Unbind in Activity.onDestroy.
- If you want to use Fragments, you must bind / unbind in Activity.