Page 1 of 1

BLE peripheral and central simultaneously

Posted: Wed Sep 08, 2021 11:21 am
by Jonas A
Hello,

we are using esp-idf 4.3 and using the device as both BLE peripheral and BLE central. When the central is trying to connect to a device using function ble_gap_connect it is impossible for a central device (mobile phone in this case) to connect to the peripheral.

Is this a known issue? Is there a workaround for this problem?

Re: BLE peripheral and central simultaneously

Posted: Sun Sep 26, 2021 6:33 pm
by chegewara
This is not an issue. Connect, scan and advertise are pretty intensive for radio and cant occupy radio at the same time.
For example it is highly advised to stop scan when you are trying to connect to peripheral and advertising should be stopped by low level API whn central is trying to connect to esp32 in peripheral mode.

Re: BLE peripheral and central simultaneously

Posted: Mon Sep 27, 2021 12:44 pm
by Jonas A
This is what the code is doing:

1) Advertising is started from on_sync() function and restarted at CONNECT and DISCONNECT event using

ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER,&adv_params, test_gap_event, NULL);

2) Every 10th second a scanning to to fins peripherals is performed using this function

rc = ble_gap_disc(own_addr_type, 5000/*600*/, &disc_params, passive_scan_event, NULL);


With another ESP32 I send CONNECT and DISCONNECT every 3rd second and sometimes this ESP32 is not able to connect to the ESP32 which is both peripheral and central. The wireshark log attached catches the unsuccessful connect that occurs sometimes. The connect request is sent in packet 8931 and as can be observed the ESP32 doesn't response to this request. How can this faulty behavior be explained? In the log you can also see that the ESP32 starts advertising 3 seconds after the connect request (packet 8938).

Re: BLE peripheral and central simultaneously

Posted: Mon Sep 27, 2021 2:18 pm
by chegewara
Sorry, i cant help you with that.
With nimble i am having similar situation trying to connect from smartphone (nrf connect) and every single time 1st connect try fails, or i am just disconnected, and 2nd connect is always success. This is something i will investigate later, and this may be not related with your issue, since i am using arduino.