BLE > How to get details from characteristics?

Ask, and ye shall receive.
mangopudding
Posts: 5
Joined: 15:50, 18 Aug 2015

BLE > How to get details from characteristics?

Postby mangopudding » 07:57, 27 Aug 2015

Hi there.

I used the LightBlue app on my Mac to get the details from my heart rate tracker device.

Screen Shot 2015-08-26 at 11.49.12 PM.png
Screen Shot 2015-08-26 at 11.49.12 PM.png (105.46 KiB) Viewed 30714 times


So in my logging code, I can see that I'm getting the right service, characteristic and descriptor info.

Code: Select all

LOG: Connecting...
LOG: Connected to device: MIO GLOBAL-FUSE
LOG: Reading services... (this may take some time)
LOG:   service: 0000180d-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a37-0000-1000-8000-00805f9b34fb
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a38-0000-1000-8000-00805f9b34fb
LOG:   service: 0000180f-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a19-0000-1000-8000-00805f9b34fb
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:   service: 6c721826-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a0a-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a0b-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a0c-5bf1-4f64-9170-381c08ec57ee
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:   service: 6c721838-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a80-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a81-5bf1-4f64-9170-381c08ec57ee
LOG:     characteristic: 6c722a82-5bf1-4f64-9170-381c08ec57ee
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 6c722a83-5bf1-4f64-9170-381c08ec57ee
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 6c722a84-5bf1-4f64-9170-381c08ec57ee
LOG:       descriptor: 00002902-0000-1000-8000-00805f9b34fb
LOG:   service: 0000180a-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a29-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a24-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a25-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a27-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a26-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a28-0000-1000-8000-00805f9b34fb
LOG:     characteristic: 00002a23-0000-1000-8000-00805f9b34fb
LOG: Done disconnecting from device


Is there some example code that will help me get the ASCII details for the characteristic?

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

Re: BLE > How to get details from characteristics?

Postby Fredrik » 15:20, 27 Aug 2015

You want the function "readCharacteristic".

We have no example that reads all characteristics on a device, but our example mbed-custom-gatt reads one characteristic in a fairly straightforward way.

"readCharacteristic" returns not a string, but an ArrayBuffer. You can use evothings.ble.fromUtf8() to try to convert the buffer to a string. Be warned, however: it will throw an exception if the buffer contains unreadable(binary) data. You can surround the call to fromUtf8() with try/catch statements to be on the safe side.

biczak
Posts: 6
Joined: 15:43, 09 Sep 2015

Re: BLE > How to get details from characteristics?

Postby biczak » 16:59, 17 Sep 2015

Is there a working example of readCharacteristic() anywhere? I too am trying to read the value of a characteristic and I can not seem to get it to work.

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

Re: BLE > How to get details from characteristics?

Postby Fredrik » 12:45, 22 Sep 2015



Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 8 guests