Handle no GSM location returned
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -347,9 +347,9 @@ void loop() {
|
|||||||
delay(15000L);
|
delay(15000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBG("Retrieving GSM location again as a string");
|
DBG("Retrieving GSM location again as a string");
|
||||||
String location = modem.getGsmLocation();
|
String location = modem.getGsmLocation();
|
||||||
DBG("GSM Based Location String:", location);
|
DBG("GSM Based Location String:", location);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS
|
#if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS
|
||||||
@@ -385,9 +385,9 @@ void loop() {
|
|||||||
delay(15000L);
|
delay(15000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBG("Retrieving GPS/GNSS/GLONASS location again as a string");
|
DBG("Retrieving GPS/GNSS/GLONASS location again as a string");
|
||||||
String gps_raw = modem.getGPSraw();
|
String gps_raw = modem.getGPSraw();
|
||||||
DBG("GPS/GNSS Based Location String:", gps_raw);
|
DBG("GPS/GNSS Based Location String:", gps_raw);
|
||||||
DBG("Disabling GPS");
|
DBG("Disabling GPS");
|
||||||
modem.disableGPS();
|
modem.disableGPS();
|
||||||
#endif
|
#endif
|
||||||
@@ -413,13 +413,14 @@ void loop() {
|
|||||||
delay(15000L);
|
delay(15000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBG("Retrieving time again as a string");
|
DBG("Retrieving time again as a string");
|
||||||
String time = modem.getGSMDateTime(DATE_FULL);
|
String time = modem.getGSMDateTime(DATE_FULL);
|
||||||
DBG("Current Network Time:", time);
|
DBG("Current Network Time:", time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TINY_GSM_TEST_GPRS
|
#if TINY_GSM_TEST_GPRS
|
||||||
modem.gprsDisconnect();
|
modem.gprsDisconnect();
|
||||||
|
delay(5000L);
|
||||||
if (!modem.isGprsConnected()) {
|
if (!modem.isGprsConnected()) {
|
||||||
DBG("GPRS disconnected");
|
DBG("GPRS disconnected");
|
||||||
} else {
|
} else {
|
||||||
@@ -454,6 +455,8 @@ void loop() {
|
|||||||
DBG("Poweroff.");
|
DBG("Poweroff.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DBG("End of tests.");
|
||||||
|
|
||||||
// Do nothing forevermore
|
// Do nothing forevermore
|
||||||
while (true) {
|
while (true) {
|
||||||
modem.maintain();
|
modem.maintain();
|
||||||
|
@@ -90,7 +90,11 @@ class TinyGsmGSMLocation {
|
|||||||
// 4 = Get longitude latitude and date time
|
// 4 = Get longitude latitude and date time
|
||||||
thisModem().sendAT(GF("+CLBS=4,1"));
|
thisModem().sendAT(GF("+CLBS=4,1"));
|
||||||
// Should get a location code of "0" indicating success
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user