Page 1 of 2

BLE multi-connection procedure

Posted: Thu Jan 12, 2017 9:21 am
by TESTTHISONE
Hello, ESP32 team.

I am implementing BLE multi-connection : one central(client) <-> many peripherals(server)
As far as I know, I have to have gatt clients for each gatt server. But it seems like each gatt client is overwriting and interfering the other gatt client in terms of callback functions and other significant variables such as gatt_if.

What is the recommended procedure for BLE multi-connection with ESP32?
Please specify the procedure in detail. If there is a sample code for reference, please provide me.

Your help is greatly appreciated :)

Regards,

Re: BLE multi-connection procedure

Posted: Wed Mar 08, 2017 7:21 pm
by Narmor
I have the sample problem. Has anyone found a Solution yet? I couldnt find anything in this forum, or the esp_idf or the BLE Documentation. *pushs topic*

Re: BLE multi-connection procedure

Posted: Thu Mar 16, 2017 1:31 pm
by romba89
I'm also interested in getting details on this. Something which hasn't been yet answered.

Re: BLE multi-connection procedure

Posted: Sun Mar 26, 2017 3:24 pm
by heyinling
Hi, multi-connection is not supported yet. some SW work need to be done before releasing this feature. plz kindly wait.

Re: BLE multi-connection procedure

Posted: Tue Jul 11, 2017 12:01 pm
by san27deep
When will it be available?
if multiple peripheral is already available then how to that? do you have any sample code?

Re: BLE multi-connection procedure

Posted: Fri Jul 14, 2017 7:25 pm
by kokonuts
Same here, would really like to use ESP32 as ble-wifi gateway, so I need to connect to 10 ble peripheral sensors. Pretty basic IoT stuff. I hope esp-IoT dev framework will support this soon.

Re: BLE multi-connection procedure

Posted: Tue Jul 18, 2017 3:08 am
by Lucas.Hutchinson
A client connecting to multiple peripherals is available in the IDF at the moment.

Currently I use multiple profiles registered using the function

Code: Select all

esp_ble_gattc_app_register
.
However you should be able to use only one profile and just refer to each device using it's own conn_id.

AS far as i am aware you will not be able to connect to 10 peripheral devices simultaneously.
In the menuconfig there is an option for max ACL connections (BLE connections). this has an allowable range of 1-7.
If you assign one of those for the peripheral side of your BLE hub, this would leave the ability to connect to 6 peripheral devices as a central.

Re: BLE multi-connection procedure

Posted: Fri Jul 21, 2017 6:23 am
by heyinling
I've tried the following scenarios with GATT service discovery/read/write/notify/indicate:
1. 4 (default max conn allowed in menuconfig) ESP32 (master + GATTC) connected to ESP32 (slave + GATTS)
2. ESP32 (master + GATTC) connect to 4 ESP32 (slave + GATTS)
3. ESP32 (master + GATTC) connect to 2 ESP32 (slave + GATTS); ESP32 (slave + GATTS) connected by 2 ESP32 (master + GATTC)
and BTW I also tried 2 ESP32 connected and each both act as GATTS + GATTC.

All the GATT behaviors succeed, except some connection have a chance to get disconnected, especially transmitting data on all connections.

And some notes for the application code:
1. multi-connection for GATTS, only need to cache the correct conn_id for each connection.
2. for GATTC, use one app for all connections, do gatt_open with different addresses (as @Lucas.Hutchinson said).
3. if you create multiple apps, connection events will be dispatch to all apps. connection will only be closed if all apps call its close API.

Re: BLE multi-connection procedure

Posted: Wed Aug 09, 2017 6:28 am
by Weijian-Espressif
hi all, Please update to the latest idf, the attachment is the multi-connection code. we would add the multi-connection demo in the v3.0

Re: BLE multi-connection procedure

Posted: Wed Aug 09, 2017 10:02 pm
by Lucas.Hutchinson
Hi Weijian,

Thanks for the example. This confirms that what I have implemented is very close to what you have in the example!