Skip to content Skip to sidebar Skip to footer

Decode Bluetooth Data From The Indoor Bike Data Characteristic

I'm trying to use the Fitness Machine Service + the Indoor Bike Data characteristic to get the cadence data. By using the nRF Connect Android App I can see that the data is there,

Solution 1:

Your bitwise operation on the flags field does not look to be correct.

I have done the following:

var ble_bytes = new Uint8Array([0x44, 0x02, 0x52, 0x03, 0x5A, 0x00, 0x08, 0x00, 0x00]).buffer;
var view = new DataView(ble_bytes)

flags = view.getUint16(0, true);
var i;
for (i = 0; i < 16; i++) {
  console.log('flags[' + i + '] = ' + (!!(flags >>> i & 1)));
}
console.log('Instantaneous Speed = ' + view.getUint16(2, true) / 100)
console.log('Instantaneous Cadence = ' + view.getUint16(4, true) * 0.5)
console.log('Instantaneous Power  = ' + view.getInt16(6, true))
console.log('Heart Rate  = ' + view.getUint8(8, true))

Which gave me the output of:

> "flags[0] = false"
> "flags[1] = false"
> "flags[2] = true"
> "flags[3] = false"
> "flags[4] = false"
> "flags[5] = false"
> "flags[6] = true"
> "flags[7] = false"
> "flags[8] = false"
> "flags[9] = true"
> "flags[10] = false"
> "flags[11] = false"
> "flags[12] = false"
> "flags[13] = false"
> "flags[14] = false"
> "flags[15] = false"
> "Instantaneous Speed = 8.5"
> "Instantaneous Cadence = 45"
> "Instantaneous Power  = 8"
> "Heart Rate  = 0"

Which indicates there is Instantaneous Cadence present, Instantaneous Power present, Heart Rate present. The field Instantaneous Speed is always present.

I've converted the bytes according to that and it seems to match with what you got from the nRF Connect app.


Post a Comment for "Decode Bluetooth Data From The Indoor Bike Data Characteristic"