Closed LynxyssCZ closed 5 years ago
I saw some comments said BLE and WiFi work together will using high heap. Currently esp32-arduino API still no fully support on both work together. Maybe u can try with do BLE scan first, after done your scan then turn to WiFi mode. This one i tried few month ago, it is worked but during switch mode to WiFi will abit slow on SSID connection.
It is not a heap issue as I still have over 30k left. Your workaround is not really realistically acceptable, as I have to perform ble scans multiple times in order to get all data off the sensors and would take hours if I wanted to maintain reasonable api uptime. I solved heap issues some time ago and they usually end up with the esp reseting, in this case it continues to run, but is completely useless.
Hi, maybe try to add small delay between some of those lines:
BLEDevice::init("");
WiFi.begin("ssid", "key");
xTaskCreate(vTaskBleReader, "BLE_READER", 4096, NULL, 1, NULL);
xTaskCreate(vTaskWebServer, "WEB_SERVER", 4096, NULL, 1, NULL);
Im just guessing now, since i didnt have any issue using ble + wifi, but its possible that the way you are initializing ble and wifi is causing radio init stuck.
@chegewara will try, although as I said in the issue both BLE and WiFi operate normally for 10-20 minutes before watchdog error appears.
Sorry @LynxyssCZ , my bad. I thought its ms here UP 52.4m Free 31864
, but its minutes, so just ignore my last post.
In such situation maybe try with different time interval and time window in BLE, or if its not a problem try latest commit from https://github.com/nkolban/esp32-snippets.
I have been searching long time ago about using BLE and WiFi at the same time in arduino and it has some issues because of task priority for Wifi and ble. Try writing this after your while cycles in your two tasks: TIMERG1.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG1.wdt_feed = 1; TIMERG1.wdt_wprotect = 0; It will feed the watchdog. If for some reason you run the tasks in core 0, just change TIMERG1 to TIMERG0. Hope it helps
@RottenVanSuti Okay, that did change the behavior. Execution now stops completely without any further logs.
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1270] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_CMPL_EVT
IP address:
192.168.0.150
UP 12.0m Free 33216
18
IP address:
192.168.0.150
UP 12.1m Free 33216
18
[D][BLEScan.cpp:196] start(): >> start(duration=2)
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
[D][BLEUtils.cpp:1229] dumpGapEvent(): [st[D][BLEUtils.cpp:1229] dumpGapEvent(): [status: 5]
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_START_COMPLETE_EVT
[D][BLEUtils.cpp:1305] dumpGapEvent(): [status: 0]
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: f8:77:b8:5f:49:95, dev_type: ESP_BT_DEVICE_TYPE_DUMO, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -85, ble_adv: ??, flag: 26 ([LE General Discoverable Mode] [Simultaneous LE and
BR/EDR to Same Device Capable (Controller)] [Simultaneous LE and BR/EDR to Same Device Capable (Host)] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -85
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 1a
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0xff (ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE), length: 26, data: 7500420401014ff877b85f4995fa77b8e5499407000000000000
[D][BLEAdvertisedDevice.cpp:399] setManufacturerData(): - manufacturer data: 7500420401014ff877b85f4995fa77b8e5499407000000000000
Device Found
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 7b:74:46:d0:17:ec, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_RANDOM, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -86, ble_adv: ??, flag: 26 ([LE General Discoverable Mode] [Simultaneous LE and BR/EDR to Same Device Capable (Controller)] [Simultaneous LE and BR/EDR to Same Device Capable (Host)] ), num_resps: 1, adv_data_len: 30, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -86
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 1a
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0xff (ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE), length: 25, data: 4c000c0e00700bf84e9dca8f3ee1116f50b210050b1c09b7c2
[D][BLEAdvertisedDevice.cpp:399] setManufacturerData(): - manufacturer data: 4c000c0e00700bf84e9dca8f3ee1116f50b210050b1c09b7c2
Device Found
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 62:28:34:52:b0:18, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_RANDOM, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -88, ble_adv: ??, flag: 26 ([LE General Discoverable Mode] [Simultaneous LE and BR/EDR to Same Device Capable (Controller)] [Simultaneous LE and BR/EDR to Same Device Capable (Host)] ), num_resps: 1, adv_data_len: 14, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -88
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 1a
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0xff (ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE), length: 9, data: 4c001005011cc54699
[D][BLEAdvertisedDevice.cpp:399] setManufacturerData(): - manufacturer data: 4c001005011cc54699
Device Found
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 7b:74:46:d0:17:ec, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_RANDOM, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -83, ble_adv: ??, flag: 26 ([LE General Discoverable Mode] [Simultaneous LE and BR/EDR to Same Device Capable (Controller)] [Simultaneous LE and BR/EDR to Same Device Capable (Host)] ), num_resps: 1, adv_data_len: 30, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -83
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 1a
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0xff (ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE), length: 25, data: 4c000c0e00700bf84e9dca8f3ee1116f50b210050b1c09b7c2
[D][BLEAdvertisedDevice.cpp:399] setManufacturerData(): - manufacturer data: 4c000c0e00700bf84e9dca8f3ee1116f50b210050b1c09b7c2
Device Found
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 7b:74:46:d0:17:ec, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_RANDOM, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -84, ble_adv: ??, flag: 26 ([LE General Discoverable Mode] [Simultaneous LE and BR/EDR to Same Device Capable (Controller)] [Simultaneous LE and BR/EDR to Same Device Capable (Host)] ), num_resps: 1, adv_data_len: 30, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -84
[D][BLEAdvertisedDevice.cpp:251]
This is the last line in the debug.
ok, the task in cpu 0 is the one that did not reset the watchdog, try replacing TIMER1 with TIMER0. @LynxyssCZ
Try writing this after your while cycles in your two tasks
Hi, do you mean, at the end of the while loop(inside the loop) or just after the loop?
@RottenVanSuti Also, I'm not able to include driver/include/driver/timer.h
to get those timers...
after your "while(true)" loops of your tasks, example: "while(true){TIMERG1.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG1.wdt_feed = 1; TIMERG1.wdt_wprotect = 0; ...rest of code} You need to include:
no timer.h @baaridunnasr
@RottenVanSuti thank you for the clarification.
However I've resolved the issue on my end as a low memory situation. The error I received was exactly the same as described in this issue, so it wasn't apparent.
Although I'm not entirely sure why low memory caused cpu starvation...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This stale issue has been automatically closed. Thank you for your contributions.
Hardware:
Board: M5Stack Core Installation version: 1.5.0 IDE name: Arduino IDE, Platform.io Flash Frequency: 80Mhz PSRAM enabled: no Upload Speed: 115200 Computer OS: Windows 10, Arch Linux
Description:
I'm trying to build a BLE sensor reader that processes temperatures and provides HTTP API for reading data. If BLE and WiFi are running together, it operates properly for 10-20minutes and then both BLE scanning and WiFi stop working and following is repeatedly printed to output.
loop
method is still executing properly.Removing either BLE or WiFi eliminates the problem.
Sketch:
Minimal sketch that exhibits the same behavior
Debug Messages: