diff --git a/src/GPSStatus.h b/src/GPSStatus.h index bcd371eb..a15e385a 100644 --- a/src/GPSStatus.h +++ b/src/GPSStatus.h @@ -63,7 +63,7 @@ class GPSStatus : public Status int32_t getLatitude() const { if (radioConfig.preferences.fixed_position){ -#if GPS_EXTRAVERBOSE +#ifdef GPS_EXTRAVERBOSE DEBUG_MSG("WARNING: Using fixed latitude\n"); #endif NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); @@ -75,7 +75,7 @@ class GPSStatus : public Status int32_t getLongitude() const { if (radioConfig.preferences.fixed_position){ -#if GPS_EXTRAVERBOSE +#ifdef GPS_EXTRAVERBOSE DEBUG_MSG("WARNING: Using fixed longitude\n"); #endif NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); @@ -87,7 +87,7 @@ class GPSStatus : public Status int32_t getAltitude() const { if (radioConfig.preferences.fixed_position){ -#if GPS_EXTRAVERBOSE +#ifdef GPS_EXTRAVERBOSE DEBUG_MSG("WARNING: Using fixed altitude\n"); #endif NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); @@ -105,7 +105,7 @@ class GPSStatus : public Status bool matches(const GPSStatus *newStatus) const { -#if GPS_EXTRAVERBOSE +#ifdef GPS_EXTRAVERBOSE DEBUG_MSG("GPSStatus.match() new pos@%x to old pos@%x\n", newStatus->p.pos_timestamp, p.pos_timestamp); #endif diff --git a/src/configuration.h b/src/configuration.h index 8f0d3cfa..628cd0bf 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -100,6 +100,10 @@ along with this program. If not, see . #define GPS_TX_PIN 12 #endif +#ifndef TTGO_T_ECHO +#define GPS_UBLOX +#endif + // ----------------------------------------------------------------------------- // LoRa SPI // ----------------------------------------------------------------------------- diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 57647472..45e3eb1a 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -54,6 +54,56 @@ bool GPS::setupGPS() _serial_gps->write("$PCAS11,3*1E\r\n"); delay(250); +#endif +#ifdef GPS_UBLOX + // 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)); + delay(250); + + // disable GGL + byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x05,0x3A}; + _serial_gps->write(_message_GGL,sizeof(_message_GGL)); + delay(250); + + // disable GSA + byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x06,0x41}; + _serial_gps->write(_message_GSA,sizeof(_message_GSA)); + delay(250); + + // disable GSV + byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x03, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x07,0x48}; + _serial_gps->write(_message_GSV,sizeof(_message_GSV)); + delay(250); + + // disable VTG + byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x09,0x56}; + _serial_gps->write(_message_VTG,sizeof(_message_VTG)); + delay(250); + + // enable RMC + byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x09,0x54}; + _serial_gps->write(_message_RMC,sizeof(_message_RMC)); + delay(250); + + // enable GGA + byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, + 0xF0, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x05, 0x38}; + _serial_gps->write(_message_GGA,sizeof(_message_GGA)); + delay(250); #endif } diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp index 73031139..7560c0b3 100644 --- a/src/gps/NMEAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -129,10 +129,16 @@ bool NMEAGPS::lookForLocation() auto loc = reader.location.value(); // Bail out EARLY to avoid overwriting previous good data (like #857) - if((toDegInt(loc.lat) == 0) || (toDegInt(loc.lat) > 90)) { + if (toDegInt(loc.lat) > 900000000) { +#ifdef GPS_EXTRAVERBOSE + DEBUG_MSG("Bail out EARLY on LAT %i\n",toDegInt(loc.lat)); +#endif return false; } - if((toDegInt(loc.lng) == 0) || (toDegInt(loc.lng) > 180)) { + if (toDegInt(loc.lng) > 1800000000) { +#ifdef GPS_EXTRAVERBOSE + DEBUG_MSG("Bail out EARLY on LNG %i\n",toDegInt(loc.lng)); +#endif return false; } diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 36d3b225..fa1b2a90 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -224,7 +224,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus) } else { // The GPS has lost lock, if we are fixed position we should just keep using // the old position -#if GPS_EXTRAVERBOSE +#ifdef GPS_EXTRAVERBOSE DEBUG_MSG("onGPSchanged() - lost validLocation\n"); #endif if (radioConfig.preferences.fixed_position) {