NimBLE how to only allow previously bonded central to connect?

steaky1212
Posts: 9
Joined: Wed Jul 27, 2022 7:43 am

NimBLE how to only allow previously bonded central to connect?

Postby steaky1212 » Thu Aug 25, 2022 4:02 pm

I'm working on a BLE peripheral using the NimBLE stack, and a key requirement is that it must only allow a single central device which has previously bonded with it to connect (until a button is pressed, clearing the stored bond and allowing a different central to bond). But figuring out how to implement this using the NimBLE library is proving very difficult.

I can either do this by doing directed advertising to the central that has bonded, or by terminating any connections (in the BLE_GAP_EVENT_CONNECT event) if there is no stored bond for the central that has just connected.

It also needs to work with private random addresses (as the phone randomises its own address and I will be using LE Privacy on the peripheral). This is the main problem I’m struggling to solve. How do I read the correctly resolved address from the stored bonds so I can do directed advertising to it, and how do I see if a stored bond exists for an existing connection?

Can this be done with the NimBLE stack and if so, how would I do it?

Thanks

Alberk
Posts: 52
Joined: Sat Jun 19, 2021 1:49 am

Re: NimBLE how to only allow previously bonded central to connect?

Postby Alberk » Fri Aug 26, 2022 12:39 am

Hi,

I am thinking out aloud. If there is there is no bonding on the ESP32 then allow any device to bond. Once there is an established bond then no bonding to the ESP32 is allowed/rejected. In this instance only the first bonded Phone/Device would be able to establish connection.

bakadave
Posts: 2
Joined: Thu Oct 26, 2023 12:39 pm

Re: NimBLE how to only allow previously bonded central to connect?

Postby bakadave » Thu Oct 26, 2023 12:40 pm

Did you manage to do tihs?

Who is online

Users browsing this forum: No registered users and 88 guests