This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How custom attributes are mapped to handles

Hi,

I am doing a communication with the custom tags which uses the custom characteristic and handle to communicate.

ServiceUuid: 81469e83-ef6f-42af-b1c6-f339dbdce2ea CharacteristicUuid: 8146c203-ef6f-42af-b1c6-f339dbdce2ea noitfyCharacteristicUuid: "8146c201-ef6f-42af-b1c6-f339dbdce2ea",

How these custom characteristics are getting mapped to the handles at BLE module side? is there any scheme how these will get mapped?

Vishal N

Parents
  • Hi Vishal,

    GATT handles (16-bit number used by GATT commands such as Write or Notify) are assigned "automatically" by GATT Server "stack". If you run GATT Server then it's a question what HW/SW stack you run bellow your app but in case of Nordic embedded devices (nRF51/52 family) it's typically Nordic Soft Device or some Open Source stack variant. These provide API to the embedded "application" so once you provision your GATT Services and other objects (like Characteristics) you will get handle numbers which will be later used during the communication (e.g. events coming to your app from the stack etc.) On GATT Client side the situation is more abstract: you should either get "list" of GATT handles "out of band" (very unusual but possible) or you need to do so-called "GATT Service Discovery" procedure. This is sequence of GATT commands which is going through ranges of handles and gives you information about what is where There is no strict sequence defined by BT SIG so every device can implement slightly different algorithm of how to go through GATT Server space (which actually has "tree" topology with Primary Services being roots of each branch). To make it simpler (or more complicated) there is mechanism how GATT Server can signal that it is "static" which means that once you do service discovery (= you will know which Service/Characteristic is on which handle number) you can cache it and use any time later without need of discovering it again.

    To conclude if you are GATT Client and you are looking for your custom Characteristic UUID you need to know what Primary Service UUID it belongs to and then you can discover it in two steps (first looking where Primary Service resides and then look where in that range your Characteristic lies). If you are on some higher platform such as Android/iOS/Windows then these systems usually do GATT Service Discovery automatically (to the extend that application even cannot forbid them to do it) and you will just operate on top of UUIDs, actual GATT handles will be translated by underlying stack (transparently to the app).

    Cheers Jan

Reply
  • Hi Vishal,

    GATT handles (16-bit number used by GATT commands such as Write or Notify) are assigned "automatically" by GATT Server "stack". If you run GATT Server then it's a question what HW/SW stack you run bellow your app but in case of Nordic embedded devices (nRF51/52 family) it's typically Nordic Soft Device or some Open Source stack variant. These provide API to the embedded "application" so once you provision your GATT Services and other objects (like Characteristics) you will get handle numbers which will be later used during the communication (e.g. events coming to your app from the stack etc.) On GATT Client side the situation is more abstract: you should either get "list" of GATT handles "out of band" (very unusual but possible) or you need to do so-called "GATT Service Discovery" procedure. This is sequence of GATT commands which is going through ranges of handles and gives you information about what is where There is no strict sequence defined by BT SIG so every device can implement slightly different algorithm of how to go through GATT Server space (which actually has "tree" topology with Primary Services being roots of each branch). To make it simpler (or more complicated) there is mechanism how GATT Server can signal that it is "static" which means that once you do service discovery (= you will know which Service/Characteristic is on which handle number) you can cache it and use any time later without need of discovering it again.

    To conclude if you are GATT Client and you are looking for your custom Characteristic UUID you need to know what Primary Service UUID it belongs to and then you can discover it in two steps (first looking where Primary Service resides and then look where in that range your Characteristic lies). If you are on some higher platform such as Android/iOS/Windows then these systems usually do GATT Service Discovery automatically (to the extend that application even cannot forbid them to do it) and you will just operate on top of UUIDs, actual GATT handles will be translated by underlying stack (transparently to the app).

    Cheers Jan

Children
Related