Closed mm108 closed 5 years ago
I moved the BT initialization to bottom ( that is after MQTT connection is successful). So now the MQTT connects properly every time but the moment I try to initialize the Bluetooth Library the ESP32 crashes. Greatly appreciate any pointers. Spent a great many hours poking at everything I possibly could.
The following lines are the ones used for initializing
Serial.println(F("Initialize Bluetooth ..."));
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
The crash log
Initialize Bluetooth ...
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4000c46c PS : 0x00060f30 A0 : 0x80129386 A1 : 0x3fff6d30
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x0000001c A5 : 0x00000000
A6 : 0x40202730 A7 : 0x00000001 A8 : 0x800ec6dd A9 : 0x3fff6cf0
A10 : 0x3ffffe9c A11 : 0x00000000 A12 : 0x00000001 A13 : 0x3ffffe0c
A14 : 0x3fffccfc A15 : 0x00000084 SAR : 0x00000008 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x4000c46c:0x3fff6d30 0x40129383:0x3fff6d40 0x40129c65:0x3fff6d60 0x40105a2d:0x3fff6d80 0x40105a67:0x3fff6da0
Rebooting...
ets Jun 8 2016 00:22:57
The result from ESP exception decoder
PC: 0x4000c46c
EXCVADDR: 0x00000000
Decoding stack results
0x40129383: bta_ar_init at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/bta/ar/bta_ar.c line 72
0x40129c65: bta_sys_init at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/bta/sys/bta_sys_main.c line 186
0x40105a2d: btu_task_start_up at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/stack/btu/btu_task.c line 301
0x40105a67: btu_task_thread_handler at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/stack/btu/btu_task.c line 226
Ok this is related to the memory issues when using WiFi + BLE. I'll work my way around this. Thanks anyways.
What do you mean related to memory issues? Having same problem. Did you work your way around this?
I am experiencing the same issue.
Using MQTT without SSL works, but with SSL either fails SSL connection or crashes system (depends on the order of invocation).
@m-menon did you find a solution for this? I'm experiencing similar issues.
It's been a long time since that project and so I don't exactly remember but I do recollect couple of things that I did back then - I moved all of the strings, certs etc to flash memory. I also remember having experimented with another mqtt library. If I can find my old source code, I'll elaborate further.
Also the BLE library/stack is somewhat heavy. You can look at the discussion here regarding that. Also if storage (size) is an issue, that can be easily tackled by altering the partition size.
If you can post a minimal program to reproduce the issue, I may be able to suggest some fixes.
Most likely its problem with memory shortage. ble is using a lot of memory and SSL connection also need a lot memory to initial connection. Try o add memory logging before SSL connection starts.
I encountered an (strange?)error when running my Arduino Sketch on a ESP32 dev board. I have two different sketches for testing purposes.
Both these works perfectly well when used independently. There's a sketch that uses both these libraries and then the ESP32 crashes repeatedly! I have tried all possibilities and poked around with the code since couple of days but I can't seem to get a fix.
I am still pretty new to ESP32/Arduino etc so any pointers would greatly help. Here are some logs. I even used the ESP Exception library to copy paste the trace and it shows me additional information regarding the crash.
The result from the ESP Exception Decoder