Parsing Bluetooth Data
Posted: July 9th, 2015, 2:04 am
I'm working with the Bluetooth LE spec of the rower and don't quite understand the spec for the rowing service. I'm currently parsing the data coming in from the rowing service and don't know how to interpret the bytes.
The spec says (for example UUID 0x0037),
I also have this question as a part of this thread: http://www.c2forum.com/viewtopic.php?f=15&t=81699
The spec says (for example UUID 0x0037),
Which means what? There are 18 bytes, and 18 fields. So each of these fields (above only the first 6 shown) has 1 byte to convey a data value. So, I assume I have a value of 0-255 to map to a real quantity. But how? I wrote this code, but to be honest I'm not sure how to interpret these bytes.Data bytes packed as follows:
Elapsed Time Lo (0.01 sec lsb),
Elapsed Time Mid,
Elapsed Time High,
Distance Lo (0.1 m lsb),
Distance Mid,
Distance High,
... etc.
Code: Select all
const uint8_t *payload = [data bytes]; // data is the characteristic.value
NSTimeInterval secondsFraction = 0.01 * (uint8_t)payload[0]; // so the byte, 0-255, is multiplied by 0.01 and that's how many 100ths of a second?? Shouldn't it then have a value somewhere between 0-99 ?
NSTimeInterval seconds = (NSTimeInterval)1.f * (uint8_t)payload[1]; // likewise, this value would be 0-59 ?
NSTimeInterval minutes = (NSTimeInterval)1.f * (uint8_t)payload[2]; // what if I am rowing for longer than 255 minutes? See, I think I don't understand...