BLE: what's the deal with handle and uuid?

Ask, and ye shall receive.
mdings
Posts: 1
Joined: 14:38, 16 Jan 2015

BLE: what's the deal with handle and uuid?

Postby mdings » 14:49, 16 Jan 2015

Hi there,

I am just starting out developing an app which connects over BLE with an in-car odbii-device. I've gone through the documentation about the plugin and built a small prototype which connects successfully to the device. Now, I have the following question: why is the handle of a service or characteristic used in the interaction-methods instead of the uuid?

For example:

Code: Select all

evothings.ble.readCharacteristic(
   deviceHandle,
   characteristic.handle,
   function(data)
   {
      console.log('BLE characteristic data: ' + evothings.ble.fromUtf8(data));
   },
   function(errorCode)
   {
      console.log('BLE readCharacteristic error: ' + errorCode);
   });


The handle seems to change after each connection while the uuid stays the same? What's the idea behind this?
The uuid seems to me something that can be cached after first connection while for a characteristic's handle to be obtanined I need to go through the sequence of connecting -> reading services -> reading characteristics.
Or am I missing something here?

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

Re: BLE: what's the deal with handle and uuid?

Postby Fredrik » 17:52, 16 Jan 2015

Theoretically, there can be more than one characteristic with the same UUID. Therefore, we need a handle to distinguish between them.

Also, the native part of the plugin needs to enumerate the objects that correspond to each characteristic; those can't be cached.

There is a JavaScript library "easyble", distributed with the Evothings examples, that allow you to use UUIDs as you describe, at the cost of some computing time and a few kilobytes of code and data space. See ti-sensortag-demo for an example.


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 56 guests