Keep only one bonded device as GATT server

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

Keep only one bonded device as GATT server

Postby maldus » Fri Nov 02, 2018 2:25 pm

Hello everyone,
I have an ESP32 set up as secure GATT server with bonding and encryption. The bonding procedure works flawlessly and from then the device remembers my smartphone for future connections.

I need to allow only one bonded device at any time: if someone else completes the bonding procedure the ESP32 should forget any previous connection. What would be the best way to do it?
For instance, I could retrieve all the bonded device with esp_ble_get_bond_device_list, but is the list ordered? If I always remove all the devices but the first (or the last), am I sure to keep the last one?

chegewara
Posts: 2240
Joined: Wed Jun 14, 2017 9:00 pm

Re: Keep only one bonded device as GATT server

Postby chegewara » Fri Nov 02, 2018 3:01 pm

Like you said, you can retrieve list of bonded devices, it is array. Then you can iterate thru that array and if mac address is not the same as currently connected/bonded device then remove it from list. Easy code and since you allow only one device to be bond at the time you will have 2 devices at most.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 267 guests