Handle no GSM location returned

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2020-02-18 22:43:39 -05:00
parent 62516d26a3
commit 37766589f8
2 changed files with 17 additions and 10 deletions

View File

@@ -420,6 +420,7 @@ void loop() {
#if TINY_GSM_TEST_GPRS
modem.gprsDisconnect();
delay(5000L);
if (!modem.isGprsConnected()) {
DBG("GPRS disconnected");
} else {
@@ -454,6 +455,8 @@ void loop() {
DBG("Poweroff.");
#endif
DBG("End of tests.");
// Do nothing forevermore
while (true) {
modem.maintain();

View File

@@ -90,7 +90,11 @@ class TinyGsmGSMLocation {
// 4 = Get longitude latitude and date time
thisModem().sendAT(GF("+CLBS=4,1"));
// Should get a location code of "0" indicating success
if (thisModem().waitResponse(120000L, GF("+CLBS:0,")) != 1) {
if (thisModem().waitResponse(120000L, GF("+CLBS:")) != 1) { return false; }
int8_t locationCode = thisModem().streamGetIntLength(2);
// 0 = success, else, error
if (locationCode != 0) {
thisModem().waitResponse(); // should be an ok after the error
return false;
}