[Question]: BLE server/peripheral support of multiple concurrent client connections?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby kolban » Fri Dec 22, 2017 6:52 pm

I have a user who is attempting to connect multiple BLE clients (centrals) to the same single BLE server (peripheral) hosted on the ESP32. What we find is that the first client connects correctly but when we attempt to connect the second client "nothing happens". What I mean by this is that there are no signs of any events arriving at the ESP32 ... it is as though the ESP32 is no longer responding to connect requests.

This Stack Exchange post says that multiple clients should be able to connect to a single server:

https://stackoverflow.com/questions/371 ... att-server

while this Adafruit article:

https://learn.adafruit.com/introduction ... nergy/gatt

says:

"The most important thing to keep in mind with GATT and connections is that connections are exclusive. What is meant by that is that a BLE peripheral can only be connected to one central device (a mobile phone, etc.) at a time!"

The net of this post is:

1) Does the BLE specification allow multiple concurrent connections into a BLE server from multiple BLE clients?
2) If yes to #1, does the ESP32 BLE stack support this concept?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: [Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby WiFive » Sat Dec 23, 2017 9:29 am

http://embedded.fm/blog/ble-roles

A peripheral advertises
A central scans
After a peripheral makes a connection it’s called a slave
After a central makes a connection it’s called a master
After a BLE connection has been established, devices can be either a client or a server

https://stackoverflow.com/questions/240 ... le-masters

Bluetooth v4.1 specs: Slaves are permitted to have physical links to more than one master at a time.

As for question #2 someone else will have to answer. The peripheral will have to be advertising for the 2nd central to connect.

phatpaul
Posts: 110
Joined: Fri Aug 24, 2018 1:14 pm

Re: [Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby phatpaul » Wed Feb 06, 2019 4:03 pm

Can someone please confirm that a BLE peripheral implemented on the ESP32 can connect simultaneously to multiple centrals?

Is it as simple as changing the GAP state-machine so that advertising continues when a central connects? Or is there more that needs to be done?

An additional article that says it can't:
"One important distinction between the master and slave device in a BLE network is that a slave may only be connected to a single master, but a master may be connected to multiple slaves." --
https://www.silabs.com/community/wirele ... e_mas-gviy

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

Re: [Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby chegewara » Wed Feb 06, 2019 6:48 pm

Hi,
what i can say is, if that silabs statement is true then i am doing something wrong because i can use esp32 as peripheral and allow to connect few central peer devices.

For sure im not as good programmer as silabs programmers, and my ble knowledge is mediocre but as far as i know it is possible. For sure it is not
as simple as changing the GAP state-machine so that advertising continues when a central connects
You have to control every attribute, indications and notifications etc. My thinking is that it is similar to web server, your app have to control data exchange between esp32 and all connected central devices.

phatpaul
Posts: 110
Joined: Fri Aug 24, 2018 1:14 pm

Re: [Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby phatpaul » Tue Feb 11, 2020 6:32 pm

I see the example gattc_multi_connect: https://github.com/espressif/esp-idf/tr ... ti_connect
But that example is for connecting ESP to 3 BLE peripherals. (ESP is the Central/GATT Client)

I suspect the implementation would be similar to that example, but for ESP32 as peripheral/GATT server <--> 3 centrals. So exactly how would I go about allowing, say 3, concurrent Central devices to connect to my ESP32?

My code is currently based on https://github.com/eagi223/esp-idf_Blue ... ti-Service

wangshuoran
Posts: 37
Joined: Fri Dec 24, 2021 12:40 pm

Re: [Question]: BLE server/peripheral support of multiple concurrent client connections?

Postby wangshuoran » Sat Mar 25, 2023 2:01 am

ESP32系列支持作为Server与多个Client相连,以官方gatt_server_service_table为例,在收到ESP_GATTS_CONNECT_EVT事件后,调用esp_ble_gap_start_advertising(&adv_params);再次开启广播即可

Who is online

Users browsing this forum: Google [Bot] and 140 guests