BLE GATT_Server and GATT_Client at the same time possible?
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
BLE GATT_Server and GATT_Client at the same time possible?
Hi all!
I apologize if this question has already been asked and answered, but I couldn't seem to find an answer.
I am looking to use the ESP32 with both WiFi and BLE.
I know that as of the ESP-IDF v2.0-RC1 Bluetooth and WIFI concurrency is now possible.
However I am wanting to setup the ESP32 as both a BLE Peripheral and a BLE central.
Use Case:
3 BLE sensor nodes distributed in one room.
ESP32 acts as BLE Central and connects to all of the sensor nodes.
The ESP32 also acts as a BLE Peripheral so a user can connect to a single BLE device (ESP32) and see all of the data from the 3 different sensor nodes.
The ESP32 will also be setup as a WiFi AP to control lights and other connected devices based on the data from the sensor nodes.
So the overarching question is:
Can the ESP32 currently be setup as both a BLE peripheral and as a BLE Central?
If this is not currently possible, are there any plans to implement this in the future?
Thanks in advance!
- Lucas
I apologize if this question has already been asked and answered, but I couldn't seem to find an answer.
I am looking to use the ESP32 with both WiFi and BLE.
I know that as of the ESP-IDF v2.0-RC1 Bluetooth and WIFI concurrency is now possible.
However I am wanting to setup the ESP32 as both a BLE Peripheral and a BLE central.
Use Case:
3 BLE sensor nodes distributed in one room.
ESP32 acts as BLE Central and connects to all of the sensor nodes.
The ESP32 also acts as a BLE Peripheral so a user can connect to a single BLE device (ESP32) and see all of the data from the 3 different sensor nodes.
The ESP32 will also be setup as a WiFi AP to control lights and other connected devices based on the data from the sensor nodes.
So the overarching question is:
Can the ESP32 currently be setup as both a BLE peripheral and as a BLE Central?
If this is not currently possible, are there any plans to implement this in the future?
Thanks in advance!
- Lucas
Last edited by Lucas.Hutchinson on Wed Mar 01, 2017 11:39 pm, edited 1 time in total.
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: BLE Concurrent Central and Peripheral possible?
Bump.
Just checking if anyone has any idea if this is possible?
Thanks in advance!
Just checking if anyone has any idea if this is possible?
Thanks in advance!
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: BLE Concurrent Central and Peripheral possible?
Hi All,
After testing out the Gatt server and client separately, I am now trying to integrate both projects into the same app.
It seems that at the moment you cant have both running at the same time.
If the Client is initialized first, the server fails to start advertising.
If the Server is initialized first, the client fails to scan.
My code is as follows:
Were 'gatt_client_main' does:
and 'gatt_server_main' does:
Is there anything that i seem to be doing incorrectly here?
Is this a feature that is not supported?
If so, will this feature ever be supported?
Thanks in advance!
After testing out the Gatt server and client separately, I am now trying to integrate both projects into the same app.
It seems that at the moment you cant have both running at the same time.
If the Client is initialized first, the server fails to start advertising.
If the Server is initialized first, the client fails to scan.
My code is as follows:
Code: Select all
esp_bt_controller_init();
if (esp_bt_controller_enable(ESP_BT_MODE_BTDM))
{
ESP_LOGE(SYRP_GATT_TAG, "Fatal Error! %s enable controller failed\n", __func__);
return;
}
if (esp_bluedroid_init())
{
ESP_LOGE(SYRP_GATT_TAG, "Fatal Error! %s init bluetooth failed\n", __func__);
return;
}
if (esp_bluedroid_enable())
{
ESP_LOGE(SYRP_GATT_TAG, "Fatal Error! %s enable bluetooth failed\n", __func__);
return;
}
gatt_client_main();
gatt_server_main();
Code: Select all
esp_err_t status;
//register the scan callback function to the gap moudule
if ((status = esp_ble_gap_register_callback(esp_gap_cb)) != ESP_OK) {
ESP_LOGE(GATTC_TAG, "gap register error, error code = %x\n", status);
return;
}
//register the callback function to the gattc module
if ((status = esp_ble_gattc_register_callback(esp_gattc_cb)) != ESP_OK) {
ESP_LOGE(GATTC_TAG, "gattc register error, error code = %x\n", status);
return;
}
esp_ble_gattc_app_register(PROFILE_A_APP_ID);
esp_ble_gattc_app_register(PROFILE_B_APP_ID);
}
Code: Select all
esp_ble_gatts_register_callback(gatts_event_handler);
esp_ble_gap_register_callback(gap_event_handler);
esp_ble_gatts_app_register(SYRP_PROFILE_APP_IDX);
ESP_LOGI(SYRP_GATT_TAG, "%s Bluetooth Server Setup Complete\n", __func__);
Is this a feature that is not supported?
If so, will this feature ever be supported?
Thanks in advance!
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: BLE GATT_Server and GATT_Client at the same time possible?
Hi all, @ESP_iggr @ESP_Angus @WiFive
Can anyone provide any answers on this.
If this is not supported, then how I am using the ESP32 in my application will likely have to change dramatically.
It would be good to know now, rather than later if and/or when this feature will be implemented.
Can anyone provide any answers on this.
If this is not supported, then how I am using the ESP32 in my application will likely have to change dramatically.
It would be good to know now, rather than later if and/or when this feature will be implemented.
Re: BLE GATT_Server and GATT_Client at the same time possible?
I have tried to implement this for nearly 10 hours as well and couldnt find a solution. It would be nice to get an official statement if this is even possible API wise.
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: BLE GATT_Server and GATT_Client at the same time possible?
Hi Narmor,
https://github.com/espressif/esp-idf/issues/404
I posted this on the github issues and got a response. It looks like it should support both modes, however you cant advertise and scan at the same time.
TianHao also said that they will do some more work on this.
https://github.com/espressif/esp-idf/issues/404
I posted this on the github issues and got a response. It looks like it should support both modes, however you cant advertise and scan at the same time.
TianHao also said that they will do some more work on this.
Re: BLE GATT_Server and GATT_Client at the same time possible?
Lucas.Hutchinson wrote:
Use Case:
3 BLE sensor nodes distributed in one room.
ESP32 acts as BLE Central and connects to all of the sensor nodes.
Hi Lucas, would you provide the sample of ESP32 Central and connected to 3 ble devices ? As far as I know it is not possible to connect to more than one ble peripheral
Re: BLE GATT_Server and GATT_Client at the same time possible?
Hi Lucas.Hutchinson
I think the limitation should be that we can't use (adv) and (scan connect) at the same time. I first let ESP32 work as GATTS, connected by a GATTC (adv auto switched off now), then connect to a GATTS. it works well on both connections with both role.
I think the limitation should be that we can't use (adv) and (scan connect) at the same time. I first let ESP32 work as GATTS, connected by a GATTC (adv auto switched off now), then connect to a GATTS. it works well on both connections with both role.
-
- Posts: 76
- Joined: Tue May 29, 2018 8:00 pm
Re: BLE GATT_Server and GATT_Client at the same time possible?
Can anyone comment on the current status of simultaneous BLE peripheral and central?
I did not see any comment on this in the "ESP32 Bluetooth Architecture" document (which, by the way, is very nicely done. Very useful guide to the platform. I wish all vendors did this for their platforms...)
I did not see any comment on this in the "ESP32 Bluetooth Architecture" document (which, by the way, is very nicely done. Very useful guide to the platform. I wish all vendors did this for their platforms...)
Re: BLE GATT_Server and GATT_Client at the same time possible?
I did not build any device that requiring ble central + peripheral, but i did quick and simple test with Neil Kolban's library and it works. What i did:
- esp32 server for testing,
- esp32 client that is connecting to esp32 server and sending messages every 1000ms + server that allows to connect another client,
- android device with nRF connect that is connecting to dual mode esp32 device.
Looking at putty logs in real time everything worked, but like i said, it was only test case and i cant say how it will works in real app. Also i have to mention it was few months ago.
- esp32 server for testing,
- esp32 client that is connecting to esp32 server and sending messages every 1000ms + server that allows to connect another client,
- android device with nRF connect that is connecting to dual mode esp32 device.
Looking at putty logs in real time everything worked, but like i said, it was only test case and i cant say how it will works in real app. Also i have to mention it was few months ago.
Who is online
Users browsing this forum: Bing [Bot] and 84 guests