Page 1 of 1
BLE Multiple Instances
Posted: Thu Mar 06, 2025 2:18 am
by litmus337
Hello.
Using Bluedroid, is it possible for peripheral BLE device have multiple BLE instances, so I can connect the peripheral to multiple centrals. It doesn't need to connect centrals concurrently, just switching communication from one central to another is OK.
If possible, how can I implement that?
Re: BLE Multiple Instances
Posted: Thu Mar 06, 2025 10:35 am
by MicroController
Should be straight forward:
When one central disconnects, you just start advertising again; then the same or a different central can (re-)connect to the peripheral.
Re: BLE Multiple Instances
Posted: Thu Mar 06, 2025 12:21 pm
by litmus337
Thanks for your fast reply.
This is actually the exact thing what I want, and this is the expected case when the central performs disconnection (and it works well). However, when I disconnect using esp_ble_gap_disconnect(), after starting advertising it reconnects automatically to the previously disconnected central. (I googled and found that it seems to be normal for hid ble peripherals)
So, the solution for my question is, to disconnect a central in "proper" way using esp_ble_gap_disconnect (or other functions), or start advertising in "proper" way. How should it be?
Re: BLE Multiple Instances
Posted: Fri Mar 07, 2025 7:56 am
by MicroController
Note that it's the central which connects to the peripheral. The central can decide to immediately try and reconnect when the connection is closed; not much the peripheral can do about that.
Re: BLE Multiple Instances
Posted: Sat Mar 08, 2025 5:11 pm
by litmus337
I found a solution that will be the worst but works. I just saved multiple MAC address in NVS memory and load the target MAC address that will be used (before BLE init). Simply restarting and set another MAC address will switch the instance.