Really got location working
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -318,6 +318,7 @@ void loop() {
|
||||
#endif
|
||||
|
||||
#if TINY_GSM_TEST_GSM_LOCATION && defined TINY_GSM_MODEM_HAS_GSM_LOCATION
|
||||
DBG("Waiting for GSM location");
|
||||
String location = modem.getGsmLocation();
|
||||
DBG("GSM Based Location String:", location);
|
||||
float lat = 0;
|
||||
@@ -328,7 +329,9 @@ void loop() {
|
||||
int day = 0;
|
||||
int hour = 0;
|
||||
int min = 0;
|
||||
int sec = 0;
|
||||
int sec = 0;
|
||||
for (int8_t i = 5; i; i--) {
|
||||
DBG("Waiting for GSM location");
|
||||
if (modem.getGsmLocation(&lat, &lon, &accuracy, &year, &month, &day, &hour,
|
||||
&min, &sec)) {
|
||||
DBG("Latitude:", String(lat, 8));
|
||||
@@ -341,12 +344,15 @@ void loop() {
|
||||
DBG("Minute:", min);
|
||||
DBG("Second:", sec);
|
||||
} else {
|
||||
DBG("Couldn't get GSM location");
|
||||
DBG("Couldn't get GSM location, retrying in 10s.");
|
||||
delay(10000L);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS
|
||||
modem.enableGPS();
|
||||
DBG("Waiting for GPS/GNSS/GLONASS location");
|
||||
String gps_raw = modem.getGPSraw();
|
||||
DBG("GPS/GNSS Based Location String:", gps_raw);
|
||||
float lat2 = 0;
|
||||
@@ -362,7 +368,9 @@ void loop() {
|
||||
int hour2 = 0;
|
||||
int min2 = 0;
|
||||
int sec2 = 0;
|
||||
if (modem.getGPS(&lat2, &lon, &speed2, &alt2, &vsat2, &usat2, &accuracy2,
|
||||
for (int8_t i = 5; i; i--) {
|
||||
DBG("Waiting for GPS/GNSS/GLONASS location");
|
||||
if (modem.getGPS(&lat2, &lon2, &speed2, &alt2, &vsat2, &usat2, &accuracy2,
|
||||
&year2, &month2, &day2, &hour2, &min2, &sec2)) {
|
||||
DBG("Latitude:", String(lat2, 8));
|
||||
DBG("Longitude:", String(lon2, 8));
|
||||
@@ -377,8 +385,11 @@ void loop() {
|
||||
DBG("Hour:", hour2);
|
||||
DBG("Minute:", min2);
|
||||
DBG("Second:", sec2);
|
||||
break;
|
||||
} else {
|
||||
DBG("Couldn't get GPS/GNSS location");
|
||||
DBG("Couldn't get GSM location, retrying in 10s.");
|
||||
delay(10000L);
|
||||
}
|
||||
}
|
||||
modem.disableGPS();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user