Skip to main content
Senior
March 2, 2021
Solved

How are the BLE attribute handle offsets defined?

  • March 2, 2021
  • 2 replies
  • 3849 views

Where can I find documentation on the BLE attribute handle offsets? I was adapting code from the sensor demo for the BLE NRG 2 and am trying to understand the "aci_gatt_attribute_modified_event" callback. Through observation and experimentation I found that adding 1 to the attribute handle identifies write characteristic events from the BLE client and adding 2 to the handle identifies characteristic notifications being enabled or disabled. I haven't seen any description of this behavior in the BLE programming guide, but I would like to know all the available offsets and what they are for.

This topic has been closed for replies.
Best answer by Winfred LU

The handles are sequentially assigned during the server initializing its services and attributes.

The client has to use the service and characteristic discovery to obtain all the handles of the attributes it is interested in.

This is not in programming guide because it is more likely to be a background knowledge for Bluetooth GATT/GAP.

https://www.bluetooth.com/bluetooth-resources/intro-to-bluetooth-gap-gatt/

2 replies

Winfred LU
Winfred LUBest answer
ST Employee
March 5, 2021

The handles are sequentially assigned during the server initializing its services and attributes.

The client has to use the service and characteristic discovery to obtain all the handles of the attributes it is interested in.

This is not in programming guide because it is more likely to be a background knowledge for Bluetooth GATT/GAP.

https://www.bluetooth.com/bluetooth-resources/intro-to-bluetooth-gap-gatt/

tguly.1
Associate II
October 12, 2023

I do not understand how this answer got marked as solution to this question.

The link in the answer contains 2 videos, both which confirms that each attribute has a unique handle.

And in the DataThroughput example from ST when a characteristics is created you get a unique handle YET when you get data for a handle sometimes it is with offset +1 or with offset +2 compared.

None of the videos above mention any offset to any handle in the BLE core spec so the question is still valid. What are those handles that are reported via the Event_Handler and why it is +1 or +2?

Furthermore, if you google for any explanation the first and only hit is this forum. "Google knows it all" as the saying goes. Except this time? Why is the only hit this forum entry?

If I google for characteristic handles I only find "each has a unique value". Nothing mentioned about "user has to calculate what handle is what". BLE Article on oracle: "The attribute handle is a unique 16-bit identifier for each attribute on a particular GATT server. "

paul19
Associate III
June 4, 2021

Hi @BPaik​ . Did you finally understand what's happening with this handle offset? @Winfred LU​ 's answer doesn't seem to help...

BPaikAuthor
Senior
June 4, 2021

I recall seeing a table that had a list of all the GATT offsets and what they correspond to. I've been searching online, but I can't seem to find it anywhere. It's strange that it so difficult to find despite being common knowledge. The two I use in my code are 1 for a write event, and a 2 for enabling notifications.

paul19
Associate III
June 5, 2021

Thanks a lot. I cannot find this table either. Hopefully one day someone will do and post it here.

Also, in the sample code, I think ST should replace the puzzling hard coded constants with meaningful #define.