BLE Multiple Instances

litmus337
Posts: 4
Joined: Thu Mar 06, 2025 1:53 am

BLE Multiple Instances

Postby litmus337 » Thu Mar 06, 2025 2:18 am

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?

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: BLE Multiple Instances

Postby MicroController » Thu Mar 06, 2025 10:35 am

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.

litmus337
Posts: 4
Joined: Thu Mar 06, 2025 1:53 am

Re: BLE Multiple Instances

Postby litmus337 » Thu Mar 06, 2025 12:21 pm

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?

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: BLE Multiple Instances

Postby MicroController » Fri Mar 07, 2025 7:56 am

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.

litmus337
Posts: 4
Joined: Thu Mar 06, 2025 1:53 am

Re: BLE Multiple Instances

Postby litmus337 » Sat Mar 08, 2025 5:11 pm

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.

Who is online

Users browsing this forum: Applebot, Bing [Bot] and 2 guests