Display Characteristic Value as a Number?
Display Characteristic Value as a Number?
I am trying to take a specific characteristic, and display its value, which is a number. Currently, my app is able to connect to the device, but it displays the characteristic's UUID instead of it's numerical value. Is it possible with JavaScript to take the characteristic's UUID and from that display the value that characteristic represents?
Re: Display Characteristic Value as a Number?
It is possible.
You'll need to call readCharacteristic() and wait for a reply from the remote device.
The reply has the type ArrayBuffer. You'll need to interpret it in the format of your number. There's a lot to choose from. Decimal string or binary? 8-bit, 16-bit or 32-bit? Big or little endian?
Here's an example that uses Uint8Array: https://github.com/evothings/evothings-examples/blob/master/examples/mbed-custom-gatt/app.js
You'll need to call readCharacteristic() and wait for a reply from the remote device.
The reply has the type ArrayBuffer. You'll need to interpret it in the format of your number. There's a lot to choose from. Decimal string or binary? 8-bit, 16-bit or 32-bit? Big or little endian?
Here's an example that uses Uint8Array: https://github.com/evothings/evothings-examples/blob/master/examples/mbed-custom-gatt/app.js
Return to “Questions and answers”
Who is online
Users browsing this forum: No registered users and 18 guests