BLE peripheral and central simultaneously

Jonas A
Posts: 16
Joined: Tue Mar 09, 2021 11:14 am

BLE peripheral and central simultaneously

Postby Jonas A » Wed Sep 08, 2021 11:21 am

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?

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

Re: BLE peripheral and central simultaneously

Postby chegewara » Sun Sep 26, 2021 6:33 pm

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.

Jonas A
Posts: 16
Joined: Tue Mar 09, 2021 11:14 am

Re: BLE peripheral and central simultaneously

Postby Jonas A » Mon Sep 27, 2021 12:44 pm

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).
Attachments
disconnect_574.png
disconnect_574.png (69.15 KiB) Viewed 3926 times

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

Re: BLE peripheral and central simultaneously

Postby chegewara » Mon Sep 27, 2021 2:18 pm

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.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 82 guests