Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to identify the BLE wheel and crank sensor data from the 11-bytes data from a mobile application we have developed

I want to identify the wheel and crank sensor data from the 11-bytes data. I have tried to parse the 11-bytes hex data which i got in our mobile application as per the split ups in the link below.

https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.csc_measurement.xml

For instance i have tried the following,

Hex Data : 0x03 6D010000 FC7E 2C01 F87E

Flag-03 ->0000 0011 -> 8bits so both are true hence we can get the wheel and crank's respective values.

Cumulative Wheel Revolutions- 6D 01 00 00 -> 32bits so converting it in decimal we get -1828782080

Last Wheel Event Time- FC 7E -> 16bits so converting it in decimal we get - 64638

Cumulative Crank Revolutions- 2C 01 -> 16bits so converting it in decimal we get - 11265

Last Crank Event Time- F8 7E -> 16bits so converting it in decimal we get - 63614

I am unable to get the actual wheel and crank measurement values from the BLE. Is the above procedure what i have understood from the reference link which i have followed is correct ? or am i wrong elsewhere ? I have put our maximum effort to dissect and parse the data but unfortunately I am unable to reach the solution. Kindly guide me through this process. What do we have to do to get the right value ? Like am i supposed to multiply it with some number ? I have tried with different combination yet not able to get. The device i am using is the SunDing515 cycling speed and cadence sensor with Bluetooth low energy.

like image 472
Santosh Krishnan Avatar asked Apr 04 '18 06:04

Santosh Krishnan


2 Answers

From your data and from the data sheet, we see that the values are using unsigned integer. (uint16 or uint8). None of your value should be negative.

Usually, bluetooth values are little endian instead of big endian. Example:

6D010000 should be read 00 00 01 6D = 365

FC7E should be read 7E FC = 32508

2C01 should be read 01 2C = 300

F87E should be read 7E F8 = 32504

like image 127
xiaomi Avatar answered Nov 09 '22 10:11

xiaomi


I don't know if you figured out what you were looking for at this, but the endian thing really helped me out. The basic process you need to do is read the data twice. Then use the difference in time and the difference in crank revolutions (i only did cranks) multiply by 1024 (as per the spec).

so assuming that you have from the little endian example: 300 for the Cumulative Crank Revolutions (CCR) and 23504 as the Last Crank Event Time (LCET) (Unit has a resolution of 1/1024s.) . Read the data again and you will get a slightly higher CCR (say 301 or 302) and a much higher LCET say 24704. Then subtract the more recent LCET from the older one (24704-23504) to get 1200 and the Higer CCR from the lower CCR (302-300) to get 2. Then multipy the CCR by 1024 and divide by the difference in the LCET. Giving you 1.7. That is your rotations per reading. Then multiply by 60 to get Rotations per minute. (102.4)

like image 35
Dennis Rutherford Avatar answered Nov 09 '22 12:11

Dennis Rutherford