How to get the correct glucose measurement value from HEX

Viewed 625

I am working on android app which is used to read sugar level from BLE device (Any Glocometer) whenever new data available. Whenever i check my sugar level through device which is connected to the app, its reads below HEX value. I am unable to parse or identify the format of this HEX value. Actual sugar level was 104 mg/dL whenever i decode this HEX value t string i get value 1 Nhø

0B 04 00 E4 07 05 0E 0C 31 1D 4E 01 68 B0 F8 00 00

// For all other profiles, writes the data formatted in HEX.
            final byte[] data = characteristic.getValue();
            if (data != null && data.length > 0) {
                final StringBuilder stringBuilder = new StringBuilder(data.length);
                for(byte byteChar : data)
                    stringBuilder.append(String.format("%02X ", byteChar));
                intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString());
            }
1 Answers

If your device uses the adopted Glucose service/characteristic, then according to the Bluetooth website, your measurement is divided as follows:-

  • Field1: Flags (8bits): 0B (1011: time offset present, type and sample TRUE, kg/L, Sensor Status True)
  • Field2: Sequence number (16bits): 04 00
  • Field3: Date Time (54 bits): E4 07 05 0E 0C 31 1D
  • Field4: Time offset (16 bits): 4E 01
  • Field5: Units kg/L: (16 bits SFLOAT): 68 0B
  • Field6: Units mol/L: (16 bits SFLOAT): NOT PRESENT
  • Field7: Type: (4bits): F
  • Field8: Location: (4bit): 8
  • Field9: Status: (16bit): 00 00

So your measurement is 68 0B. 68 is 104 which is in line with your measurement. Not sure what the 0B is for and how it is used, but it can be discarded for now.

I hope this helps.

Related