Skip to content

Commit

Permalink
changed: sendSMS to make the parsing of the answer from module more t…
Browse files Browse the repository at this point in the history
…olerant
  • Loading branch information
Peter Kövesdi committed Feb 19, 2023
1 parent ecc0c38 commit 20e9c79
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions Adafruit_FONA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,24 +894,20 @@ bool Adafruit_FONA::sendSMS(char *smsaddr, char *smsmsg) {

DEBUG_PRINTLN("^Z");

if ((_type == FONA3G_A) || (_type == FONA3G_E)) {
// Eat two sets of CRLF
readline(200);
// DEBUG_PRINT("Line 1: "); DEBUG_PRINTLN(strlen(replybuffer));
readline(200);
// DEBUG_PRINT("Line 2: "); DEBUG_PRINTLN(strlen(replybuffer));
}
readline(10000); // read the +CMGS reply, wait up to 10 seconds!!!
// DEBUG_PRINT("Line 3: "); DEBUG_PRINTLN(strlen(replybuffer));
if (strstr(replybuffer, "+CMGS") == 0) {
return false;
}
readline(1000); // read OK
// DEBUG_PRINT("* "); DEBUG_PRINTLN(replybuffer);

if (strcmp(replybuffer, "OK") != 0) {
return false;
}
char ltimeout = 0;
do {
readline(10000);
ltimeout++;
if (ltimeout > 5)
return false;
} while (strstr(replybuffer, "+CMGS") == NULL);
ltimeout = 0;
do {
readline(200);
ltimeout++;
if (ltimeout > 5)
return false;
} while (strcmp(replybuffer, "OK") != 0);

return true;
}
Expand Down

0 comments on commit 20e9c79

Please sign in to comment.