1

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]

sopuz
  • 85
  • 6

1 Answers1

3

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.

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • thanks for your reply @ukBaz i checked glucose related services for `Accu-Chek guide` and it only supports `Glucose` service `0x1808`. on my original question, i meant to say `Glucose Measurement` instead of `Glucose Feature`. im assuming the base64 decoded value from `Glucose Measurement` characteristic should correspond to the fields of `XML for Glucose Measurement`? if so, im receiving array w/ 20 elements instead of 9. – sopuz Aug 11 '20 at 00:38
  • I've updated the answer with more detail on how to unpack the 20 bytes you are receiving for the 9 fields. – ukBaz Aug 11 '20 at 06:15
  • I have decoded responses from Glucose Measurement successfully. But how to get Glucose Measurement Context responses then? I have already subscribed to this characteristic together with Glucose Measurement & RACP. Do I need to write another request to RACP? – programmer dreamer Jan 10 '22 at 05:15
  • 1
    The `Glucose Measurement Context` characteristic is a variable-length structure which is detailed in the [GATT Specification Supplement 5](https://www.bluetooth.com/specifications/specs/gatt-specification-supplement-5/) document. If you need more information it should be a new question. – ukBaz Jan 10 '22 at 06:50
  • All those XML resources are not available any more. Do you know where the information moved to or if there is any alternative? – Edvard Jun 30 '22 at 09:14
  • The Bluetooth SIG now document this in the `GATT Specification Supplement` document at https://www.bluetooth.com/specifications/specs/. The format is quite different but the information should be in there. – ukBaz Jun 30 '22 at 09:46