Unable to make bluetooth GATT connection to a service

I did not write this code, but coincidentally I am trying to do exactly what this code does (i.e. read the battery status of an LiTime 12V battery via bluetooth), but on a Particle MSOM running 6.2.1 instead of a browser. Scroll to the bottom, line 155 to see the relevant function.

The code above works well, but I need to do it on a Particle device. As far as I can tell, the battery level is only available via a GATT connection to the 0xFFE0 service. However, the Particle BLE library does not seem to have the necessary capabilities to request/read that. For example, the following methods (or similar) do not exist:
gatt.connect()
getPrimaryService(0xFFE0)
getServices()
getCharacteristics()
etc.

Am I missing something? Is there another library I could use? How can I work around this issue?

It should be possible, but the code will be quite a bit different. It should be similar to heart rate central.

  • The scan and connect in that example replace the gatt.connect().
  • You should not need to obtain the service. You typically just pass the service UUID and characteristic UUID when you retrieve it, in a single step.

Thanks for the help! I was able to get it finally, but you do have to get the service first.

BleUuid serviceUuid(0xFFE0);
BleService batteryService;
_batteryDevice.getServiceByUUID(batteryService, serviceUuid)
BleUuid charUuid(0xFFE1);
_batteryDevice.getCharacteristicByUUID(batteryService, _batteryStatusCharacteristic, charUuid)

I tried putting the service inline with the second call and it failed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.