fix #327 side effect noticed by @smarti2019

This commit is contained in:
geeksville 2020-08-22 09:06:54 -07:00
parent a90bab5455
commit 7b09fbe049

View File

@ -102,8 +102,13 @@ bool UBloxGPS::factoryReset()
// It is useful to force back into factory defaults (9600baud, NEMA to test the behavior of boards that don't have // It is useful to force back into factory defaults (9600baud, NEMA to test the behavior of boards that don't have
// GPS_TX connected) // GPS_TX connected)
ublox.factoryReset(); ublox.factoryReset();
delay(3000); delay(5000);
tryConnect(); // sets isConnected tryConnect(); // sets isConnected
// try a second time, the ublox lib serial parsing is buggy?
if (!tryConnect())
tryConnect();
DEBUG_MSG("GPS Factory reset success=%d\n", isConnected); DEBUG_MSG("GPS Factory reset success=%d\n", isConnected);
if (isConnected) if (isConnected)
ok = setUBXMode(); ok = setUBXMode();
@ -122,12 +127,11 @@ int UBloxGPS::prepareSleep(void *unused)
void UBloxGPS::doTask() void UBloxGPS::doTask()
{ {
uint8_t fixtype = 3; // If we are only using the RX pin, assume we have a 3d fix if (isConnected) {
assert(isConnected);
// Consume all characters that have arrived // Consume all characters that have arrived
uint8_t fixtype = 3; // If we are only using the RX pin, assume we have a 3d fix
// if using i2c or serial look too see if any chars are ready // if using i2c or serial look too see if any chars are ready
ublox.checkUblox(); // See if new data is available. Process bytes as they come in. ublox.checkUblox(); // See if new data is available. Process bytes as they come in.
@ -145,9 +149,9 @@ void UBloxGPS::doTask()
if (ublox.getT(maxWait)) { if (ublox.getT(maxWait)) {
/* Convert to unix time /* Convert to unix time
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January
(midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
*/ */
struct tm t; struct tm t;
t.tm_sec = ublox.getSecond(0); t.tm_sec = ublox.getSecond(0);
t.tm_min = ublox.getMinute(0); t.tm_min = ublox.getMinute(0);
@ -185,9 +189,10 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
const meshtastic::GPSStatus status = const meshtastic::GPSStatus status =
meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites); meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites);
newStatus.notifyObservers(&status); newStatus.notifyObservers(&status);
}
// Once we have sent a location once we only poll the GPS rarely, otherwise check back every 1s until we have something over // Once we have sent a location once we only poll the GPS rarely, otherwise check back every 10s until we have something
// the serial // over the serial
setPeriod(hasValidLocation && !wantNewLocation ? 30 * 1000 : 10 * 1000); setPeriod(hasValidLocation && !wantNewLocation ? 30 * 1000 : 10 * 1000);
} }