espressif / esp32-wifi-lib

ESP32 WiFi stack precompiled libraries
Apache License 2.0
167 stars 71 forks source link

BLE crashes from Wifi issue #13

Open wzaggle opened 6 years ago

wzaggle commented 6 years ago

System still crashes Ble search on some form of Wifi disconnect.

I (11552633) wifi: bcn_timout,ap_probe_send_start I (11555134) wifi: ap_probe_send over, resett wifi status to disassoc I (11555135) wifi: state: run -> init (1) I (11555135) wifi: pm stop, total sleep time: 0/-1385824691

Then remaining heap starts to go down by 2948 bytes for each esp_ble_gap_start_scanning(5); and BLE search stops finding servers but no apparent errors.

Then eventual system restart from lack of memory.

wzaggle commented 6 years ago

I am using the Arduino IDE, and this delay of 1800 ms seemed to (sort of) fix it, following an Open event and prior to getting a battery service characteristic. More or Less delay does NOT work. Will now run for hours without crashing but eventually only sees one or two out of 10 BLE Servers. Also a small delay after getting ESP_GAP_BLE_SCAN_RESULT_EVT callback cured some of the other dual BLE/Wifi issues. And a delay of 4000ms following Wifi start allowed Wifi and BLE to both start if Wifi starts first. I am confident I have only relieved a symptom and not addressed the real issues. But offered this to those who are looking for the real problems.

case ESP_GATTC_OPEN_EVT: conn_id = param->open.conn_id; if (param->open.status == ESP_GATT_OK) { delay(1800); esp_ble_gattc_get_characteristic(appGattcIf, conn_id, &batt_service_id, NULL); } break;

Additional problems seem to occur when a DISCONNECT event callback happens before a CLOSE event callback, following a failed GET CHARACTERISTIC call. After this happens a system crash is soon to follow.