Page 1 of 1

Simultaneous BLE Scanning/Advertising

Posted: Fri Sep 24, 2021 7:29 am
by Jonas A
Hi,
is it possible to scan and advertise at the same time use the integrated BLE in ESP32? I use NIMBLE stack and version 4.3 of the ESP-IDF.
Can I start advertising and periodically scan for other devices without stopping advertising?

I added a Wireshark BLE sniffer log. The central can't connect to the ESP32 sometimes. ESP32 doesn't respond to the CONNECT_IND which is sent in packet 8931.

Re: Simultaneous BLE Scanning/Advertising

Posted: Fri Sep 24, 2021 4:38 pm
by captain_morgan
Yes, this does work. The application I'm currently working on does like this....

* ble init...
* from on_sync...
* start advertising
* start discovery
* in ble_gap_event....
* use BLE_GAP_EVENT_DISC to handle client connectiong
* on BLE_GAP_EVENT_CONNECT, DISCONNECT, ADV_COMPLETE restart advertising

The code for this can be found here. https://gitlab.com/morganrallen/barback ... main/ble.c

Re: Simultaneous BLE Scanning/Advertising

Posted: Fri Sep 24, 2021 9:53 pm
by chegewara
Short answer, YES, it is possible, just make sure you dont setup very short interval and window for scan and very short advertising interval.

Re: Simultaneous BLE Scanning/Advertising

Posted: Mon Sep 27, 2021 12:13 pm
by Jonas A
I scan during 5 sec with an interval of 10 sec. Is that ok? I constantly advertise.

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

When I restart advertising do I need to call these functions:

ble_gap_adv_stop
ble_gap_adv_start

Or do I only need to call this function:

ble_gap_adv_start

Re: Simultaneous BLE Scanning/Advertising

Posted: Thu Feb 03, 2022 6:59 pm
by AjeethC
Hi,

I would like to know whether the advertising is not stopped while scanning for other devices since esp32 has a shared antenna for both purposes.