Hi,
I'm stuck in handling errors using the "return" structure
In my main code
void loop() {
if(!NachrichtSenden(1, 0)) {Serial.println("error");};
delay(10000);
}
I call that function.
bool sendMsg(int code, long dauer) {
char msg [] = "01305222020_18412212.311110000035000";
bool resp = false;
resp = SendGPRS(msg);
if (resp == false) {
Serial.print("No success sending");
return false;
}
else {
Serial.print("Success sending");
return true;
}
}
Within that one I call the next one (makes sense in the full context):
bool SendGPRS( char msg [37]) {
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
Serial.println(" [fail]");
delay(10000);
return false;
}
If now modem.gprsConnect is returning "false" the " [fail]" is printed but then I get
Stack smashing protect failure!
abort() was called at PC 0x400d6320 on core 1
Backtrace: 0x4008b560:0x3ffb1e20 0x4008b78d:0x3ffb1e40 0x400d6320:0x3ffb1e60 0x400d20aa:0x3ffb1e80 0x400d2292:0x3ffb1f30 0x400d2315:0x3ffb1f90 0x400d2ea9:0x3ffb1fb0 0x40088215:0x3ffb1fd0
I assume I did something wrong with the "return" but really no clue what. Origin to my code is that example: TinyGSM/WebClient.ino at master · vshymanskyy/TinyGSM · GitHub
Line 187 is the "modem.gprsConnect" call. The main difference is, that TinyGSM uses the "return" to stop the code and start the loop function again. That works for me as well, but in my case the "return" is in a function inside another functoin...
Thanks a lot for your help!
Markus