Post by rrrrpa on Feb 10, 2024 18:21:50 GMT
I have been fighting a problem where the return from modem.sendSMS is not reliable. I find the sendSMS is always successful but the return routinely reports that it failed. After much frustration I dove into the library to better understand what's happening.
I have identified an issue in the library for "boolean Botletics_modem::sendSMS(const char *smsaddr, const char *smsmsg)".
According to the library for the SIM7000A, two CRLFs are expected prior to the +CMGS reply.
THIS IS WRONG. I have replaced the code with:
for (int i = 0; i < 3; i++) {
readline(30000); // look for the +CMGS reply, wait up to 30s
DEBUG_PRINT("sendSMS: i = "); DEBUG_PRINT(i);
DEBUG_PRINT("\tlength = "); DEBUG_PRINT(strlen(replybuffer));
DEBUG_PRINT("\tcontent = "); DEBUG_PRINTLN(replybuffer);
if (strstr(replybuffer, "+CMGS") != 0) {
readline(1000); // read the OK reply
DEBUG_PRINT("sendSMS: i = "); DEBUG_PRINT(i);
DEBUG_PRINT("\tlength = "); DEBUG_PRINT(strlen(replybuffer));
DEBUG_PRINT("\tcontent = "); DEBUG_PRINTLN(replybuffer);
if (strstr(replybuffer, "OK") != 0) {
return true;
}
return false;
}
}
return false;
and found that sometimes 2 each CRLFs are returned, but usually neither is returned and the +CMGS reply is immediately received. MAYBE THIS IS A TIMING ISSUE? Has anyone else experienced the same? Am I overlooking something?
Please see the captured evidence below (phone number is modified). All of the captured show no CRLFs, and the 2:00 and 5:00 SMSs reportedly failed due to what looks to me to be a GMT time stamp? Neither failed; both were received.
01:00:16.255 -> Requesting Network Status
01:00:16.288 -> ---> AT+CGREG?
01:00:16.288 -> <--- +CGREG: 0,1
01:00:16.320 -> Network status = 1 -> Registered (home)
01:00:16.353 -> Sending SMS:
01:00:16.389 -> ---> AT+CMGF=1
01:00:16.389 -> <--- OK
01:00:16.423 -> ---> AT+CMGS="001925......."
01:00:16.966 -> <--- >
01:00:17.636 -> sendSMS: i = 0 length = 10 content = +CMGS: 137
01:00:17.702 -> sendSMS: i = 0 length = 2 content = OK
01:00:17.734 -> sendSMS was Successful
02:00:45.000 -> Requesting Network Status
02:00:45.033 -> ---> AT+CGREG?
02:00:45.033 -> <--- +CGREG: 0,1
02:00:45.066 -> Network status = 1 -> Registered (home)
02:00:45.098 -> Sending SMS:
02:00:45.132 -> ---> AT+CMGF=1
02:00:45.132 -> <--- OK
02:00:45.178 -> ---> AT+CMGS="001925......."
02:00:45.678 -> <--- >
02:00:47.331 -> sendSMS: i = 0 length = 6 content = DST: 0
02:00:47.396 -> sendSMS: i = 1 length = 35 content = *PSUTTZ: 24/02/05,10:00:46","-32",0
02:01:17.742 -> sendSMS: i = 2 length = 0 content =
02:01:17.783 -> sendSMS Failed
03:00:30.305 -> Requesting Network Status
03:00:30.337 -> ---> AT+CGREG?
03:00:30.337 -> <--- +CGREG: 0,1
03:00:30.370 -> Network status = 1 -> Registered (home)
03:00:30.403 -> Sending SMS:
03:00:30.435 -> ---> AT+CMGF=1
03:00:30.435 -> <--- OK
03:00:30.468 -> ---> AT+CMGS="001925......."
03:00:31.008 -> <--- >
03:00:31.845 -> sendSMS: i = 0 length = 10 content = +CMGS: 139
03:00:31.877 -> sendSMS: i = 0 length = 2 content = OK
03:00:31.910 -> sendSMS was Successful
04:00:13.041 -> Requesting Network Status
04:00:13.074 -> ---> AT+CGREG?
04:00:13.107 -> <--- +CGREG: 0,1
04:00:13.107 -> Network status = 1 -> Registered (home)
04:00:13.172 -> Sending SMS:
04:00:13.172 -> ---> AT+CMGF=1
04:00:13.206 -> <--- OK
04:00:13.206 -> ---> AT+CMGS="001925......."
04:00:13.765 -> <--- >
04:00:14.307 -> sendSMS: i = 0 length = 10 content = +CMGS: 140
04:00:14.339 -> sendSMS: i = 0 length = 2 content = OK
04:00:14.373 -> sendSMS was Successful
05:00:30.310 -> Requesting Network Status
05:00:30.342 -> ---> AT+CGREG?
05:00:30.342 -> <--- +CGREG: 0,1
05:00:30.375 -> Network status = 1 -> Registered (home)
05:00:30.407 -> Sending SMS:
05:00:30.440 -> ---> AT+CMGF=1
05:00:30.440 -> <--- OK
05:00:30.473 -> ---> AT+CMGS="001925......."
05:00:31.026 -> <--- >
05:00:32.594 -> sendSMS: i = 0 length = 6 content = DST: 0
05:00:32.627 -> sendSMS: i = 1 length = 35 content = *PSUTTZ: 24/02/05,13:00:31","-32",0
05:01:02.986 -> sendSMS: i = 2 length = 0 content =
05:01:03.028 -> sendSMS Failed
06:00:15.320 -> Requesting Network Status
06:00:15.352 -> ---> AT+CGREG?
06:00:15.385 -> <--- +CGREG: 0,1
06:00:15.385 -> Network status = 1 -> Registered (home)
06:00:15.451 -> Sending SMS:
06:00:15.451 -> ---> AT+CMGF=1
06:00:15.451 -> <--- OK
06:00:15.483 -> ---> AT+CMGS="001925......."
06:00:16.007 -> <--- >
06:00:16.786 -> sendSMS: i = 0 length = 10 content = +CMGS: 142
06:00:16.818 -> sendSMS: i = 0 length = 2 content = OK
06:00:16.851 -> sendSMS was Successful
07:00:26.333 -> Requesting Network Status
07:00:26.366 -> ---> AT+CGREG?
07:00:26.400 -> <--- +CGREG: 0,1
07:00:26.400 -> Network status = 1 -> Registered (home)
07:00:26.432 -> Sending SMS:
07:00:26.465 -> ---> AT+CMGF=1
07:00:26.497 -> <--- OK
07:00:26.497 -> ---> AT+CMGS="001925......."
07:00:27.022 -> <--- >
07:00:27.849 -> sendSMS: i = 0 length = 10 content = +CMGS: 143
07:00:27.882 -> sendSMS: i = 0 length = 2 content = OK
07:00:27.915 -> sendSMS was Successful
08:00:39.063 -> Requesting Network Status
08:00:39.096 -> ---> AT+CGREG?
08:00:39.129 -> <--- +CGREG: 0,1
08:00:39.129 -> Network status = 1 -> Registered (home)
08:00:39.194 -> Sending SMS:
08:00:39.194 -> ---> AT+CMGF=1
08:00:39.227 -> <--- OK
08:00:39.227 -> ---> AT+CMGS="001925......."
08:00:39.790 -> <--- >
08:00:40.398 -> sendSMS: i = 0 length = 10 content = +CMGS: 144
08:00:40.431 -> sendSMS: i = 0 length = 2 content = OK
08:00:40.507 -> sendSMS was Successful
I have identified an issue in the library for "boolean Botletics_modem::sendSMS(const char *smsaddr, const char *smsmsg)".
According to the library for the SIM7000A, two CRLFs are expected prior to the +CMGS reply.
THIS IS WRONG. I have replaced the code with:
for (int i = 0; i < 3; i++) {
readline(30000); // look for the +CMGS reply, wait up to 30s
DEBUG_PRINT("sendSMS: i = "); DEBUG_PRINT(i);
DEBUG_PRINT("\tlength = "); DEBUG_PRINT(strlen(replybuffer));
DEBUG_PRINT("\tcontent = "); DEBUG_PRINTLN(replybuffer);
if (strstr(replybuffer, "+CMGS") != 0) {
readline(1000); // read the OK reply
DEBUG_PRINT("sendSMS: i = "); DEBUG_PRINT(i);
DEBUG_PRINT("\tlength = "); DEBUG_PRINT(strlen(replybuffer));
DEBUG_PRINT("\tcontent = "); DEBUG_PRINTLN(replybuffer);
if (strstr(replybuffer, "OK") != 0) {
return true;
}
return false;
}
}
return false;
and found that sometimes 2 each CRLFs are returned, but usually neither is returned and the +CMGS reply is immediately received. MAYBE THIS IS A TIMING ISSUE? Has anyone else experienced the same? Am I overlooking something?
Please see the captured evidence below (phone number is modified). All of the captured show no CRLFs, and the 2:00 and 5:00 SMSs reportedly failed due to what looks to me to be a GMT time stamp? Neither failed; both were received.
01:00:16.255 -> Requesting Network Status
01:00:16.288 -> ---> AT+CGREG?
01:00:16.288 -> <--- +CGREG: 0,1
01:00:16.320 -> Network status = 1 -> Registered (home)
01:00:16.353 -> Sending SMS:
01:00:16.389 -> ---> AT+CMGF=1
01:00:16.389 -> <--- OK
01:00:16.423 -> ---> AT+CMGS="001925......."
01:00:16.966 -> <--- >
01:00:17.636 -> sendSMS: i = 0 length = 10 content = +CMGS: 137
01:00:17.702 -> sendSMS: i = 0 length = 2 content = OK
01:00:17.734 -> sendSMS was Successful
02:00:45.000 -> Requesting Network Status
02:00:45.033 -> ---> AT+CGREG?
02:00:45.033 -> <--- +CGREG: 0,1
02:00:45.066 -> Network status = 1 -> Registered (home)
02:00:45.098 -> Sending SMS:
02:00:45.132 -> ---> AT+CMGF=1
02:00:45.132 -> <--- OK
02:00:45.178 -> ---> AT+CMGS="001925......."
02:00:45.678 -> <--- >
02:00:47.331 -> sendSMS: i = 0 length = 6 content = DST: 0
02:00:47.396 -> sendSMS: i = 1 length = 35 content = *PSUTTZ: 24/02/05,10:00:46","-32",0
02:01:17.742 -> sendSMS: i = 2 length = 0 content =
02:01:17.783 -> sendSMS Failed
03:00:30.305 -> Requesting Network Status
03:00:30.337 -> ---> AT+CGREG?
03:00:30.337 -> <--- +CGREG: 0,1
03:00:30.370 -> Network status = 1 -> Registered (home)
03:00:30.403 -> Sending SMS:
03:00:30.435 -> ---> AT+CMGF=1
03:00:30.435 -> <--- OK
03:00:30.468 -> ---> AT+CMGS="001925......."
03:00:31.008 -> <--- >
03:00:31.845 -> sendSMS: i = 0 length = 10 content = +CMGS: 139
03:00:31.877 -> sendSMS: i = 0 length = 2 content = OK
03:00:31.910 -> sendSMS was Successful
04:00:13.041 -> Requesting Network Status
04:00:13.074 -> ---> AT+CGREG?
04:00:13.107 -> <--- +CGREG: 0,1
04:00:13.107 -> Network status = 1 -> Registered (home)
04:00:13.172 -> Sending SMS:
04:00:13.172 -> ---> AT+CMGF=1
04:00:13.206 -> <--- OK
04:00:13.206 -> ---> AT+CMGS="001925......."
04:00:13.765 -> <--- >
04:00:14.307 -> sendSMS: i = 0 length = 10 content = +CMGS: 140
04:00:14.339 -> sendSMS: i = 0 length = 2 content = OK
04:00:14.373 -> sendSMS was Successful
05:00:30.310 -> Requesting Network Status
05:00:30.342 -> ---> AT+CGREG?
05:00:30.342 -> <--- +CGREG: 0,1
05:00:30.375 -> Network status = 1 -> Registered (home)
05:00:30.407 -> Sending SMS:
05:00:30.440 -> ---> AT+CMGF=1
05:00:30.440 -> <--- OK
05:00:30.473 -> ---> AT+CMGS="001925......."
05:00:31.026 -> <--- >
05:00:32.594 -> sendSMS: i = 0 length = 6 content = DST: 0
05:00:32.627 -> sendSMS: i = 1 length = 35 content = *PSUTTZ: 24/02/05,13:00:31","-32",0
05:01:02.986 -> sendSMS: i = 2 length = 0 content =
05:01:03.028 -> sendSMS Failed
06:00:15.320 -> Requesting Network Status
06:00:15.352 -> ---> AT+CGREG?
06:00:15.385 -> <--- +CGREG: 0,1
06:00:15.385 -> Network status = 1 -> Registered (home)
06:00:15.451 -> Sending SMS:
06:00:15.451 -> ---> AT+CMGF=1
06:00:15.451 -> <--- OK
06:00:15.483 -> ---> AT+CMGS="001925......."
06:00:16.007 -> <--- >
06:00:16.786 -> sendSMS: i = 0 length = 10 content = +CMGS: 142
06:00:16.818 -> sendSMS: i = 0 length = 2 content = OK
06:00:16.851 -> sendSMS was Successful
07:00:26.333 -> Requesting Network Status
07:00:26.366 -> ---> AT+CGREG?
07:00:26.400 -> <--- +CGREG: 0,1
07:00:26.400 -> Network status = 1 -> Registered (home)
07:00:26.432 -> Sending SMS:
07:00:26.465 -> ---> AT+CMGF=1
07:00:26.497 -> <--- OK
07:00:26.497 -> ---> AT+CMGS="001925......."
07:00:27.022 -> <--- >
07:00:27.849 -> sendSMS: i = 0 length = 10 content = +CMGS: 143
07:00:27.882 -> sendSMS: i = 0 length = 2 content = OK
07:00:27.915 -> sendSMS was Successful
08:00:39.063 -> Requesting Network Status
08:00:39.096 -> ---> AT+CGREG?
08:00:39.129 -> <--- +CGREG: 0,1
08:00:39.129 -> Network status = 1 -> Registered (home)
08:00:39.194 -> Sending SMS:
08:00:39.194 -> ---> AT+CMGF=1
08:00:39.227 -> <--- OK
08:00:39.227 -> ---> AT+CMGS="001925......."
08:00:39.790 -> <--- >
08:00:40.398 -> sendSMS: i = 0 length = 10 content = +CMGS: 144
08:00:40.431 -> sendSMS: i = 0 length = 2 content = OK
08:00:40.507 -> sendSMS was Successful