This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Background operation of BLE Library with Android 8 - Request for Example

I would like to ask Nordic to create an example of an Android background service that can detect a device advertising.

Android imposes background execution limits which affect scanning for devices. The issue for beacons is described here and a solution implemented in the Android Beacon Library. Of course, the issue affects all devices and not just beacons. I have asked about this in an earlier post and since then done a fairly ugly implementation.

To set the context: I am working on a digital health sensor with a BLE interface. The user operates the sensor which collects data and saves it. It then starts advertising and will transfer the data when the sensor and the smart phone are next in radio range. The phone then transfers the reading to the cloud. The user does not need to have his phone when he operates the medical device, and he does not need to fire up an app manually in order to send the data to the cloud.

I have an experimental Android app that combines Nordic's Android BLE Library and the Android Beacon Library. I have hacked the Android Beacon Library to listen for my custom 128-bit UUID. This works in Android background mode. When the app detects my BLE custom UUID it fires an event and then I switch over to Nordic's BLE Library to connect to my device and transfer data. (This is obviously out of scope for the Andorid Beacon Library).

Clearly my specific use case can can be generalised: it should be possible for any BLE sensor (not just beacons) to send data to a phone that the user sees as "off".

Most of the time this works very well. But (a) my hack of the Android Beacon Library is pretty ugly, and (b) sometimes my app does not hear my device advertising and I must reset the phone. This is probably because of (a). Also, (c) the Android Beacon Library contains much more code than my app requires.

I would much prefer to work with one library and not two. What chance is the that I can get Nordic to work with me on this? The spec is to create an example Android app that listens for a BLE device in background mode, connects to it, transfers data and disconnects. I would work with you on this.

Parents Reply
  • Hi Aleksander (and others at Nordic). I have had reason to return to this project and so to this thread.

    I wonder if you would be interested in picking up this project, and making it your own? Reminder: it is an Android app that listens for an advertising device (a modification of the Health Thermometer example), connects to it then disconnects. It uses your Android BLE Scanner Compat library which is able to run in background mode, and so connects to the Android phone even when the app is in the background, and even after the phone has been powered off.

    I think it deals with an important use case - collecting data from sensors without user action. 

    I would prefer if you guys could look at it closely, clean it up, check I am using the library correctly, and perhaps write it up as an example for others. 

Children
Related