1

I am building a ReactNative application that will receive the data from another machine/ device via BLE. I am using this package, https://www.npmjs.com/package/react-native-ble-plx to implement the BLE logic. Now, I am having a problem decoding the characteristic value that I received from the monitor function.

This is my code

char.monitor((err, cha) => {
            if (err) {
                console.log("Monitoring error");
                console.log(err);
                return
            }

            console.log("char data received")
            console.log(base64.decode(cha.value))
            console.log(cha.value)
        })

When the data is received, as you can see I am base64-decoding it to get its original value. But it seems that the data is not decoded into the right format.

For example,

This is the original value

/hkABQAAMgAA//9kIwAAAACqAAEAAAAAigMAAA==

But it is decoded into the following value.

 þ↓♣2ÿÿd#ª☺Š♥

As you can see it is not readable at all. The decoded value even contains the weird characters. I am using this ReactNative base64 package, https://www.npmjs.com/package/react-native-base64. What is missing in my code and how can I fix it?

This is the service UUID, 00001826-0000-1000-8000-00805F9B34FB and this is the characteristic UUID, 00002AD1-0000-1000-8000-00805F9B34FB.

Also, this documentation might be useful because I am trying to receive data from WaterRower machine, https://github.com/WaterRower-UK/WaterRowerData-iOS/blob/master/Sources/WaterRowerData-BLE/FTMS_v1.0.pdf.

Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
  • What do you expect to receive from the rower? It most definetly does not return a string containing the information like "current speed: 5km/h". BLE data is sent bytewise and your decoded value would be `0xfe3f3f32ffff6423aa3f3f` in hex. It's hard to say what the values stand for without a documentation, it could be the first two as a timestamp, the next two for speed, ... Could you add the uuid of the service and the characteristic from which you are getting the value? Maybe it is one of the standard ones – Michael Kotzjan Jul 09 '21 at 04:39
  • Hello, I just updated the question to include UUIDs, please have a look. – Wai Yan Hein Jul 09 '21 at 08:22
  • I have also included a link to a documentation which I think might be useful. – Wai Yan Hein Jul 09 '21 at 08:26
  • The characteristic you are reading from is "Rower Data" (Section 4.8 in your document). The first two bytes are suppose to be a flags field, but I can't figure it out right now. Have a look at this document as well for the correct data field sizes: https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/rd-0000001050725868-V5 Maybe I can make some sense out of it later on, but I hope this helps you for now – Michael Kotzjan Jul 09 '21 at 08:57
  • Yes, I will give it a go. Thanks. – Wai Yan Hein Jul 09 '21 at 09:03
  • I was looking into that and honestly, I am struggling to relate the actual data string with the specification. – Wai Yan Hein Jul 09 '21 at 09:13

0 Answers0