Android Question BLE2 passing multiple service IDs in iOS but not in Android

simonwilliamson

Member
Licensed User
When my app connects to a LE Bluetooth device, the device sends a set of services every second to my app.

When one of these services values change I need to perform a task but as I can have several of the same BT device connected I also need to know which device has sent the service. I can't use the serviceID as it will be the same for all of the connected devices.

In the B4i version when Manager_DataAvailable is triggered I get ALL of the current serviceIDs passed in the Characteristics Map so can see the devices serial number in another service. However, in the B4a version it only seems to send the service with the ID I added in the SetNotify command and therefore cannot then search for the other service that contains the devices serial number.

I can't add the serial number service in the SetNotify command because the serial number value never changes and therefore never triggers the DataAvailable Sub.

How can I get all of the serviceIDs (or at least the relevant ones) passed to the Characteristics Map upon the subs triggering?

(I am using wes58's ble3 version because the LE device was not connecting using Ble2, but this is based off the ble2 library so should perform the same)
 
Solution
You are getting the platform behavior, however there are many ways to workaround it.
Best solution is to implement the BLE related code in a class instance and create a class instance for each connection. This way you can have all the information you need in the class.

The non-class option is to use a Map that maps between the BleManager object and any other value you need. You can then get that data using the Sender keyword.

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are getting the platform behavior, however there are many ways to workaround it.
Best solution is to implement the BLE related code in a class instance and create a class instance for each connection. This way you can have all the information you need in the class.

The non-class option is to use a Map that maps between the BleManager object and any other value you need. You can then get that data using the Sender keyword.
 
Upvote 0
Solution
Top