0

I have created a simple BLE advertiser using Python's dbus Library (Bluez 5.48). This sample application adds one service, and and this service has 2 characteristics. On starting advertiser, all services and Characterictic UUID will be assigned a 16 bit long ATT Handle so that Client can directly read or write on those UUIDs using HANDLEs.

Advertiser works perfectly fine, and Client can subscribe to UUIDs. However Client expects a fixed ATT Handle for both UUIDs. But Advertiser swaps the ATT Handles when reconnected.

So is there any way by which I can either 1- Keep my ATT Handles static. 2- Or Advertiser should know ATT handles assigned to UUIDs.

I have spent good amount of time in finding this out, but got no success so far.

Using this code to create advertiser. https://github.com/ukBaz/python-bluezero/blob/master/bluezero/peripheral.py

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Ekayaa
  • 169
  • 16

1 Answers1

0

I think that BlueZ tries to do the right thing looking at this:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/settings-storage.txt

The issue is likely to be that it only does it with paired devices and that example has security turned off. I can't remember how to turn it on off the top of my head. I'll try to find some time later to take a look.

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • So you mean if we turn security ON, Handles won't be changed, or I will be able to get Handle details on Advertiser side ? – Ekayaa Jul 23 '20 at 15:13
  • My expectation was that if pairing is was enabled it would then cache the attributes so the handles wouldn't change. From my brief experiments that doesn't seem to be the case. The documentation seems to suggest that a cache should be created for all connection types. The attributes file mentioned in the docs does not seem to be created https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/settings-storage.txt#n38 – ukBaz Jul 23 '20 at 19:28
  • Maybe a queston for the developers of BlueZ. http://www.bluez.org/contact/ – ukBaz Jul 23 '20 at 19:29