2016-10-24 19:34:02 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <Sodaq_UBlox_GPS.h>
|
|
|
|
|
2016-10-27 16:14:29 +00:00
|
|
|
void gpsSetup() {
|
|
|
|
sodaq_gps.init(GPS_ENABLE);
|
2016-11-27 19:03:44 +00:00
|
|
|
}
|
2016-10-27 16:14:29 +00:00
|
|
|
|
|
|
|
/* FIXME: find out power consumption if turned off */
|
|
|
|
// void gpsStop() { sodaq_gps.off(); }
|
|
|
|
|
2016-10-24 19:34:02 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Find a GPS fix, but first wait a while
|
|
|
|
*/
|
|
|
|
String gpsGetPostion(long waittime)
|
|
|
|
{
|
2016-10-27 16:14:29 +00:00
|
|
|
String res = "";
|
2016-10-24 19:34:02 +00:00
|
|
|
uint32_t timeout = waittime * 1000;
|
|
|
|
|
2016-11-15 10:32:51 +00:00
|
|
|
YELLOW();
|
2016-10-24 19:34:02 +00:00
|
|
|
debugSerial.println(String("waiting for fix ..., timeout=") + timeout + String("ms"));
|
|
|
|
|
|
|
|
uint32_t start = millis();
|
|
|
|
|
|
|
|
if (sodaq_gps.scan(false, timeout)) {
|
|
|
|
debugSerial.println(String(" time to find fix: ") + (millis() - start) + String("ms"));
|
|
|
|
debugSerial.println(String(" datetime = ") + sodaq_gps.getDateTimeString());
|
|
|
|
|
|
|
|
res = String("lat=") + String(sodaq_gps.getLat(), 7) + " " + String("lon=") + String(sodaq_gps.getLon(), 7) + " " + String("sats=") + String(sodaq_gps.getNumberOfSatellites());
|
|
|
|
|
|
|
|
debugSerial.println(res);
|
|
|
|
} else {
|
|
|
|
debugSerial.println("GPS: No Fix");
|
|
|
|
}
|
2016-11-15 10:32:51 +00:00
|
|
|
|
|
|
|
CLEAR();
|
|
|
|
|
2016-10-24 19:34:02 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
String gpsGetDateTime(long waittime) {
|
|
|
|
String res = "";
|
|
|
|
uint32_t timeout = waittime * 1000;
|
|
|
|
if (sodaq_gps.scan(false, timeout)) {
|
|
|
|
res= String("datetime =") + sodaq_gps.getDateTimeString();
|
|
|
|
debugSerial.println(res);
|
2016-10-27 16:14:29 +00:00
|
|
|
} else {
|
|
|
|
debugSerial.println("GPS: No Fix");
|
2016-10-24 19:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|