diff --git a/src/configuration.h b/src/configuration.h
index c48a279bc..e2fd3f44d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -100,10 +100,6 @@ along with this program. If not, see .
#define GPS_TX_PIN 12
#endif
-#ifndef TTGO_T_ECHO
-#define GPS_UBLOX
-#endif
-
// -----------------------------------------------------------------------------
// LoRa SPI
// -----------------------------------------------------------------------------
@@ -118,6 +114,10 @@ along with this program. If not, see .
#endif
+#ifndef TTGO_T_ECHO
+#define GPS_UBLOX
+#endif
+
//
// Standard definitions for !ESP32 targets
//
diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp
index 41fbef360..a7ed9e920 100644
--- a/src/gps/GPS.cpp
+++ b/src/gps/GPS.cpp
@@ -96,12 +96,16 @@ bool GPS::setupGPS()
delay(250);
#endif
#ifdef GPS_UBLOX
+ delay(250);
// Set the UART port to output NMEA only
byte _message_nmea[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00,
0x01, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x91, 0xAF};
_serial_gps->write(_message_nmea,sizeof(_message_nmea));
-
+ if (!getACK(0x06, 0x00)) {
+ DEBUG_MSG("WARNING: Unable to enable NMEA Mode.\n");
+ return true;
+ }
// disable GGL
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
@@ -335,6 +339,15 @@ int32_t GPS::runOnce()
if (whileIdle()) {
// if we have received valid NMEA claim we are connected
setConnected();
+ } else {
+#ifdef GPS_UBLOX
+ // reset the GPS on next bootup
+ if(devicestate.did_gps_reset && (millis() > 60000)) {
+ DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
+ devicestate.did_gps_reset = false;
+ nodeDB.saveToDisk();
+ }
+#endif
}
// If we are overdue for an update, turn on the GPS and at least publish the current status
diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp
index 8a8181f3b..4b0baee66 100644
--- a/src/gps/NMEAGPS.cpp
+++ b/src/gps/NMEAGPS.cpp
@@ -17,6 +17,19 @@ static int32_t toDegInt(RawDegrees d)
return r;
}
+bool NMEAGPS::factoryReset()
+{
+#ifdef GPS_UBLOX
+ // Factory Reset
+ byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF,
+ 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
+ _serial_gps->write(_message_reset,sizeof(_message_reset));
+ delay(1000);
+#endif
+return true;
+}
+
bool NMEAGPS::setupGPS()
{
GPS::setupGPS();
diff --git a/src/gps/NMEAGPS.h b/src/gps/NMEAGPS.h
index 6133925dd..6ef560962 100644
--- a/src/gps/NMEAGPS.h
+++ b/src/gps/NMEAGPS.h
@@ -25,6 +25,8 @@ class NMEAGPS : public GPS
public:
virtual bool setupGPS() override;
+ virtual bool factoryReset() override;
+
protected:
/** Subclasses should look for serial rx characters here and feed it to their GPS parser
*
diff --git a/src/main.cpp b/src/main.cpp
index 4c11d096e..69bc01cdd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -567,6 +567,7 @@ void setup()
// ONCE we will factory reset the GPS for bug #327
if (gps && !devicestate.did_gps_reset) {
+ DEBUG_MSG("GPS FactoryReset requested\n");
if (gps->factoryReset()) { // If we don't succeed try again next time
devicestate.did_gps_reset = true;
nodeDB.saveToDisk();