Open DirkGmailMeintjies opened 1 year ago
i have the same issue, disabling "Report adv data and scan response individually when BLE active scan" solved the problem for me, i have activated this option previously but not really know what is doing, reponses seems to be triggered one by one by bluedroid, btw
@ilovebt9 @DirkGmailMeintjies Thank you for reporting the problem. Could you please provide the complete log to help us analyze the issue?
same for me on head with WROOM32D
[1B][0;32mI (31) boot: ESP-IDF v5.4-dev-421-g4523f2d674 2nd stage bootloader[1B][0m[1B][0;32mI (523) main_task: Started on CPU0[1B][0m
[1B][0;32mI (533) main_task: Calling app_main()[1B][0m
[1B][0;32mI (533) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [1B][0m
[1B][0;32mI (543) BTDM_INIT: BT controller compile version [8a84778][1B][0m
[1B][0;32mI (543) BTDM_INIT: Bluetooth MAC: d8:..:3e[1B][0m
[1B][0;32mI (553) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06[1B][0m
[1B][0;32mI (953) BLE: ble_init finished.[1B][0m
[1B][0;31mE (953) BT_BTM: BTM_BleScan scan already active[1B][0m
[1B][0;33mW (963) BT_APPL: bta_dm_ble_scan start scan failed. status=0x6
[1B][0m
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT is only triggered when esp_ble_gap_stop_scanning is called. If esp_ble_gap_start_scanning(10) is called, scanning will stop after 10 seconds, which means ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT event will not be generated, only ESP_GAP_BLE_SCAN_RESULT_EVT event will be generated.
@DirkGmailMeintjies @mrx23dot When modem sleep is activated, the device will enter sleep mode if there is no TX or RX activity. If you believe there are still issues related to MODEM_SLEEP, please provide us with more information(such as menuconfig file). (Top) → Component config → Bluetooth → Bluetooth → Bluetooth controller → MODEM SLEEP Options [*] Bluetooth Modem sleep Mode 1
@mrx23dot When a scan is already in progress, calling esp_ble_gap_start_scanning again will result in an error, which is expected behavior.
Answers checklist.
General issue report
When calling esp_ble_gap_start_scanning(10) then current increases by ~70mA (ESP32-C3) and I get gap callback for:
ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT ESP_GAP_BLE_SCAN_START_COMPLETE_EVT ESP_GAP_BLE_SCAN_RESULT_EVT
And then ESP_GAP_BLE_SCAN_RESULT_EVT repeats for every advertisement message. After 10 seconds I get no more callbacks for ESP_GAP_BLE_SCAN_RESULT_EVT, but also no ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT callback to say scanning ended... Previous versions I did get the ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT callback after 10 seconds. Also the current stays >70mA so internally the BLE radio is still switched on.
If I then call esp_ble_gap_stop_scanning() then I see error output:
(278895) BT_BTM: BTM_BleScan scan not active (278895) BT_APPL: bta_dm_ble_scan stop scan failed, status=0x6
and I get gap callback ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT with error parameter.
But if I call esp_ble_gap_stop_scanning() before the 10 seconds pass (i.e. while still scanning) then I get successful gap callback ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, and also the current drops again by 70mA - so the radio is switched off.
The problem is: Previous versions switched the radio off itself when scanning time is over and calls gap callback event ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT. New v5.0.1 does not call callback event and does not turn off radio. I cannot call esp_ble_gap_stop_scanning() after scan time because I get error message and current stays high (BT radio stays switched on).