androidencodingcharacter-encodingbluetooth-lowenergyarraybuffer

Decode BLE Glucometer characteristics value


I am using a BLE device to read glucose value and get it on my system, but I am stuck on how to parse the encoded value returning from the glucometer characteristics value.

for eg: I am getting [27, 15, 0, 232, 7, 1, 30, 5, 58, 27, 83, 1, 111, 176, 248, 0, 0] in response from the BLE device, and I am supposed to convert it to exactly 6.2.

example of another reading:

Characteristics value: [27, 13, 0, 232, 7, 1, 29, 11, 21, 52, 83, 1, 115, 176, 248, 0, 0] Device Reading: 6.4

BLE device used: Accucheck Glucometer

Documentation Link - using this we got the above array, but unable to decode to a particular device value. a code snippet i tried - https://stackblitz.com/edit/javascript-vxbwzb?file=index.js

So, need help to find out the correlation between the required glucose value and the encoded value being sent from the device.


Solution

  • const bits = [27, 15, 0, 232, 7, 1, 30, 5, 58, 27, 83, 1, 111, 176, 248, 0, 0];
    console.log((bits[12]/18).toFixed(1))
    

    In array we are getting value at 12th bit in mg/dl unit. Then we can convert it to mmol/l by dividing it with 18. Then we can get the answer in mmol/l