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

Android-BLE-Library using LiveData with several services on the same peripheral

Hello,

I am currently developing an Android library to connect a smartphone with a peripheral device that serves several bluetooth services. BAS, DIS and 2 other private services.

For this development, I use the Android-BLE-Library 2.2.4 from Nordic and more precisely its "LiveData" declination.

Referring to the "nRF-Blinky" example, I think I understood that only one BleManager object is needed to properly manage the BLE connection and the access to services and features.

My question is the following: How do I get my BleManager implemented so that it can handle all the services available on the connected device?

Kind Regards 

Patrice

  • Hello,

    When a device connects, you will get isRequiredServiceSupported method call, where you'll get the BluetoothGatt object. In that method you should get references to all characteristics and descriptors that you need, from all your services. Your may organize them whatever you like and expose any API from the Ble Manager as you want, e.g. create method that will return LiveData objects with parsed characteristic values, organize them in services/plugins/modules, etc. How the manager is visible from outside is up to you, but internally it should have references to Gatt attributes so it can send and receive data.

    You may also take a look at nRF Toolbox, where battery level is handled in a base class, from which (almost) all other managers derive. That is another way of doing it.

Related