Simultaneous BLE Scanning/Advertising

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

Simultaneous BLE Scanning/Advertising

Postby Jonas A » Fri Sep 24, 2021 7:29 am

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

captain_morgan
Posts: 42
Joined: Wed Dec 09, 2015 6:39 pm

Re: Simultaneous BLE Scanning/Advertising

Postby captain_morgan » Fri Sep 24, 2021 4:38 pm

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

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

Re: Simultaneous BLE Scanning/Advertising

Postby chegewara » Fri Sep 24, 2021 9:53 pm

Short answer, YES, it is possible, just make sure you dont setup very short interval and window for scan and very short advertising interval.

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

Re: Simultaneous BLE Scanning/Advertising

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

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

AjeethC
Posts: 1
Joined: Thu Feb 03, 2022 6:55 pm

Re: Simultaneous BLE Scanning/Advertising

Postby AjeethC » Thu Feb 03, 2022 6:59 pm

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.

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 394 guests