Display Characteristic Value as a Number?

Ask, and ye shall receive.
biczak
Posts: 6
Joined: 15:43, 09 Sep 2015

Display Characteristic Value as a Number?

Postby biczak » 16:47, 16 Sep 2015

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?

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Display Characteristic Value as a Number?

Postby Fredrik » 13:11, 22 Sep 2015

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


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 4 guests