react-nativebluetoothbase64react-native-ble-plx

How to decode response from Glucose Measurement Characteristic (Bluetooth)


I have an react-native application and im trying to get Glucose Measurements from Accu-Chek Guide device.

I have limited knowledge on BLE and this stackoverflow question helped me a lot to understand bluetooth and retrieving glucose measurements. Reading from a Notify Characteristic (Ionic - Bluetooth)

so, what im doing in my code:

1, connect to BLE Peripheral
2, monitor characteristic Glucose Feature & Record Access Control Point
3, send 0x0101 (Report stored records | All records) to Record Access Control Point
4, decode response

So far i have 1-3 working but i dont know how to decode the response from Glucose Feature:

Notification response of Glucose Measurement

[27, 4, 0, 195, 164, 7, 7, 14, 11, 6, 5, 90, 2, 119, 194, 176, 195, 184, 0, 0]


Notification of Record Access Control Point

[6, 0, 1, 1]


Solution

  • I am assuming this is the Bluetooth SIG adopted profile of Continuous Glucose Monitoring Service (CGMS) the specification of which is available from:

    https://www.bluetooth.com/specifications/gatt/

    Looking at the XML for the Glucose Measurement characteristic, gives more detail on how the data is structured.

    https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.glucose_measurement.xml

    There will be a little bit of work to do to unpack the data.

    For example, the first byte stores the information for the first field named flags. However you need to look at the first 5 bits for those various flags.

    The next field is "Sequence Number" which is a uint16 so will take two bytes. Worth noting here that Bluetooth typically uses little endian.

    Next is the Base Time field which refers to https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.date_time.xml which will take the next 7 bytes.

    Because some of the 9 fields in the characteristic take more than one byte, this is why you are seeing 20 bytes for the 9 fields.