botletics / SIM7000-LTE-Shield

Botletics SIM7000 LTE CAT-M1/NB-IoT Shield for Arduino
https://www.botletics.com/products/sim7000-shield
GNU General Public License v3.0
477 stars 215 forks source link

Adafruit MQTT Demo causes esp32 panic #271

Open mgenova79 opened 2 years ago

mgenova79 commented 2 years ago

I have a sketch that I made about a year ago with the SIM7000 and an esp32 to datalog some temperature information and upload to Adafruit IO via MQTT ove LTE, it worked fine the last time I used it. Today I tried to use my old sketch and it caused the esp32 to panic and reboot constantly. I thought maybe my sketch had become corrupt so I downloaded a new copy of your demo in the library and I have the same issue at the exact same line. When the function MQTT_Connect() is called it crashes. i did some more debugging and found the source of the problem but I am not skilled enough to fix the problem. In the MQTT_connect function, the code that causes the panic is:

// Stop if already connected. if (mqtt.connected()) { return; }

I traced the error into AdafruitMQTT Library, more specifically the file Adafruit_MQTTFONA.h. at line 47 there is a function call

bool connected() { // Return true if connected, false if not connected. return fona->TCPconnected(); }

when return fona->TCPconnected() is called it causes the panic. I tried tracing the TCPconnected function but am unable to locate it.

I'm currently trying to make an LTE enabled GPS tracker with the esp32. I ordered a new ESP32 and hooked it up, same problem. I uninstalled Arduino IDE, reinstalled a fresh copy of arduino IDE and all associated libraries, same problem.

I'm wondering if AdafruitIO changed something on their end that breaks the code. Anyway, if someone could look into this I would greatly appreciate it. The SIM7000 has been a great dev board that has worked fine for me until now. I may try reverting back to HTTP instead of MQTT this weekend if I have time and see if that still works. If I have any success I will report back.

mgenova79 commented 2 years ago

So after much hair loss and google searching I was able to remedy the issue. ESP32 compiled no problem but panicked when running the code, so I bought a Seeeduino XIAO (SAMD M0) board and the code wouldn't even compile, stating compile error in the Adafruit_MQTT library file Adafruit_MQTT.cpp line 26,

static char *dtostrf(double val, signed char width, unsigned char prec, char *sout) {

was defined extern and later static. So I removed static from line 26 and the code compiles for the Seeeduino XIAO. I reverted back to the ESP32 to see if that fixed the problem and everything is working fine now with no panic. I'm not sure if this is the proper way to fix this but it seems everything is working fine now.