Android Question BLE2 Getting real time steps values

Hi
The LightBlue App connects to Mi band 5 ( smart band) and gives the following values for real time steps : Service UUID: 0000fee0-0000-1000-8000-00805f9b34fb, Characteristic UUDI :00000007-0000-3512-2118-0009af100700. After subscribing, when I walk, the following values ( in Hex) are shown :
0C 0C 00 00 00 00 00 00 00 00 00 00 00 ' This is first Step
0C 0E 00 00 00 00 00 00 00 00 00 00 00
0C 0F 00 00 00 00 00 00 00 00 00 00 00
0C 11 00 00 00 00 00 00 00 00 00 00 00
0C 12 00 00 00 00 00 00 00 00 00 00 00 ' This is last Step
How do I extract the steps value from the above data ? I would like to use this in B4X BLE example code to get the real time steps value.
I have attached screen shot of the readings for reference
Screenshot_2020-10-07-08-35-48-584_com.punchthrough.lightblueexplorer.jpg
 
Are you able to connect and read the data with the BLE example?
Yes, but I used BLE Central code from the BLE Peripheral thread .
Please note that I had to enable 'discoverable' (turn on to be visible to nearby devices) in the Mi Band 5 companion app to connect the smart band to the code.
The nrf connect and LightBlue App worked without enabling the 'discoverable'.


In the logs, I get the following 'Hex from Byte Value'. This is different from what I get in LightBlue App,
B4X:
Hex from Bytes value 0C99010000FD00000008000000
Hex from Bytes value 0C9A010000FD00000008000000
Hex from Bytes value 0C9B010000FD00000008000000
Hex from Bytes value 0C9C010000FD00000008000000
Hex from Bytes value 0C9D010000FD00000008000000
Hex from Bytes value 0C9E010000FD00000008000000
Hex from Bytes value 0C9F010000FD00000008000000
Hex from Bytes value 0CA0010000FD00000008000000
Hex from Bytes value 0CA1010000FD00000008000000
Hex from Bytes value 0CA3010000FD00000008000000
Hex from Bytes value 0CA30100000D01000009000000
** Activity (main) Pause, UserClosed = false **

In case you need the full log, it is attached in the text file.
 

Attachments

  • real time steps log.txt
    6.1 KB · Views: 157
Upvote 0
Thank you for your help. I was able to connect using the BLE example code too after enabling 'discoverable' (turn on to be visible to nearby devices) in the Mi Band 5 companion app. I used the BLE Central code because it was easier to swap the ServiceId and ReadChar variables in the code and subscribe to the real time steps characteristic.
Now I just need to display the steps. I found old c function to get mi band steps in Pangliang's git repository. Could you please translate this into b4x routine?
B4X:
public void onNotify(byte[] data) {
                Log.d(TAG, Arrays.toString(data));
                if (data.length == 4) {
                    int steps = data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF);
                    listener.onNotify(steps);
                }
            }
 
Upvote 0
Thank you for all the help. The c code seems to be superfluous. In the end, I just logged this and got the real time steps which matched the display on the band :) :

B4X:
Dim b() As Byte = Characteristics.Get(c)
    Log (b(1) )' Real Time No. of Steps
 
Upvote 0
Top