From 5b456bb082aab124da9f222294ad551449b80691 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 10 Oct 2025 22:54:25 -0500 Subject: [PATCH 1/7] Properly format timestamp in log message --- src/gps/RTC.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 665a9aaa34..692f3c2d2f 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -310,7 +310,7 @@ RTCSetResult perhapsSetRTC(RTCQuality q, struct tm &t) #ifdef BUILD_EPOCH if (tv.tv_sec < BUILD_EPOCH) { if (Throttle::isWithinTimespanMs(lastTimeValidationWarning, TIME_VALIDATION_WARNING_INTERVAL_MS) == false) { - LOG_WARN("Ignore time (%ld) before build epoch (%ld)!", printableEpoch, BUILD_EPOCH); + LOG_WARN("Ignore time (%lu) before build epoch (%lu)!", printableEpoch, BUILD_EPOCH); lastTimeValidationWarning = millis(); } return RTCSetResultInvalidTime; @@ -319,7 +319,7 @@ RTCSetResult perhapsSetRTC(RTCQuality q, struct tm &t) // Calculate max allowed time safely to avoid overflow in logging uint64_t maxAllowedTime = (uint64_t)BUILD_EPOCH + FORTY_YEARS; uint32_t maxAllowedPrintable = (maxAllowedTime > UINT32_MAX) ? UINT32_MAX : (uint32_t)maxAllowedTime; - LOG_WARN("Ignore time (%ld) too far in the future (build epoch: %ld, max allowed: %ld)!", printableEpoch, + LOG_WARN("Ignore time (%lu) too far in the future (build epoch: %lu, max allowed: %lu)!", printableEpoch, (uint32_t)BUILD_EPOCH, maxAllowedPrintable); lastTimeValidationWarning = millis(); } From de9401bb5cb661f078838e14660affc72dd3dccb Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 10 Oct 2025 22:55:05 -0500 Subject: [PATCH 2/7] Better formatting of GPS_DEBUG logging in gps probe --- src/gps/GPS.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 2cfa558edb..5a3c198bbc 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1484,12 +1484,12 @@ GnssModel_t GPS::getProbeResponse(unsigned long timeout, const std::vector= 2 && response[responseLen - 2] == '\r' && response[responseLen - 1] == '\n')) { -#ifdef GPS_DEBUG - LOG_DEBUG(response); -#endif // check if we can see our chips for (const auto &chipInfo : responseMap) { if (strstr(response, chipInfo.detectionString.c_str()) != nullptr) { +#ifdef GPS_DEBUG + LOG_DEBUG(response); +#endif LOG_INFO("%s detected", chipInfo.chipName.c_str()); delete[] response; // Cleanup before return return chipInfo.driver; @@ -1497,6 +1497,9 @@ GnssModel_t GPS::getProbeResponse(unsigned long timeout, const std::vector= 2 && response[responseLen - 2] == '\r' && response[responseLen - 1] == '\n') { +#ifdef GPS_DEBUG + LOG_DEBUG(response); +#endif // Reset the response buffer for the next potential message responseLen = 0; response[0] = '\0'; From d13a3c1ad502aa37f52a1056ce4764530728e2ad Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 10 Oct 2025 22:55:42 -0500 Subject: [PATCH 3/7] Reset GPS after serial speed change, and look for magic string to identify chip --- src/gps/GPS.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 5a3c198bbc..aa9a82f4ac 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1286,6 +1286,20 @@ GnssModel_t GPS::probe(int serialSpeed) memset(&ublox_info, 0, sizeof(ublox_info)); delay(100); +#ifdef PIN_GPS_RESET + digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); // assert for 10ms + delay(10); + digitalWrite(PIN_GPS_RESET, !GPS_RESET_MODE); + + // attempt to detect the chip based on boot messages + std::vector airoha = {{"AG3335", "$PAIR021,AG3335", GNSS_MODEL_AG3335}, + {"AG3352", "$PAIR021,AG3352", GNSS_MODEL_AG3352}, + {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}}; + GnssModel_t detectedDriver = getProbeResponse(500, airoha, serialSpeed); + if (detectedDriver != GNSS_MODEL_UNKNOWN) { + return detectedDriver; + } +#endif // Close all NMEA sentences, valid for L76K, ATGM336H (and likely other AT6558 devices) _serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n"); delay(20); @@ -1586,8 +1600,6 @@ GPS *GPS::createGps() #ifdef PIN_GPS_RESET pinMode(PIN_GPS_RESET, OUTPUT); - digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); // assert for 10ms - delay(10); digitalWrite(PIN_GPS_RESET, !GPS_RESET_MODE); #endif From f8e77fbd0ab8c92db547cc5751c6ef09082fb475 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 11 Oct 2025 12:11:38 -0500 Subject: [PATCH 4/7] Add UC6580 to boot message detection, for Heltec Tracker --- src/gps/GPS.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index aa9a82f4ac..d29de10fd7 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1294,7 +1294,8 @@ GnssModel_t GPS::probe(int serialSpeed) // attempt to detect the chip based on boot messages std::vector airoha = {{"AG3335", "$PAIR021,AG3335", GNSS_MODEL_AG3335}, {"AG3352", "$PAIR021,AG3352", GNSS_MODEL_AG3352}, - {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}}; + {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}, + {"UC6580", "UC6580", GNSS_MODEL_UC6580}}; GnssModel_t detectedDriver = getProbeResponse(500, airoha, serialSpeed); if (detectedDriver != GNSS_MODEL_UNKNOWN) { return detectedDriver; From 05ef5a411a0fe34a650dee0c41aaceac2bafa515 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 11 Oct 2025 12:31:16 -0500 Subject: [PATCH 5/7] Add L76K detect from boot string, for Heltec-v4 --- src/gps/GPS.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index d29de10fd7..c8a2545d8b 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1295,7 +1295,8 @@ GnssModel_t GPS::probe(int serialSpeed) std::vector airoha = {{"AG3335", "$PAIR021,AG3335", GNSS_MODEL_AG3335}, {"AG3352", "$PAIR021,AG3352", GNSS_MODEL_AG3352}, {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}, - {"UC6580", "UC6580", GNSS_MODEL_UC6580}}; + {"UC6580", "UC6580", GNSS_MODEL_UC6580}, + {"L76K", "SW=URANUS", GNSS_MODEL_MTK}}; GnssModel_t detectedDriver = getProbeResponse(500, airoha, serialSpeed); if (detectedDriver != GNSS_MODEL_UNKNOWN) { return detectedDriver; From d42c64fedbd314e29ca8609d7054a9c2952fe314 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 11 Oct 2025 17:21:41 -0500 Subject: [PATCH 6/7] Slightly more useful GPS debugging --- src/gps/GPS.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index c8a2545d8b..a63eb1d16b 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -240,6 +240,9 @@ GPS_RESPONSE GPS::getACK(const char *message, uint32_t waitMillis) buffer[bytesRead] = b; bytesRead++; if ((bytesRead == 767) || (b == '\r')) { +#ifdef GPS_DEBUG + LOG_DEBUG(debugmsg.c_str()); +#endif if (strnstr((char *)buffer, message, bytesRead) != nullptr) { #ifdef GPS_DEBUG LOG_DEBUG("Found: %s", message); // Log the found message @@ -247,9 +250,6 @@ GPS_RESPONSE GPS::getACK(const char *message, uint32_t waitMillis) return GNSS_RESPONSE_OK; } else { bytesRead = 0; -#ifdef GPS_DEBUG - LOG_DEBUG(debugmsg.c_str()); -#endif } } } From e3ed9c6c99eda136b4b7854d863490b927a8c72c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 11 Oct 2025 19:39:22 -0500 Subject: [PATCH 7/7] Back out detection of L76K via startup messages. --- src/gps/GPS.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index a63eb1d16b..d83fc8c4ca 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1292,11 +1292,13 @@ GnssModel_t GPS::probe(int serialSpeed) digitalWrite(PIN_GPS_RESET, !GPS_RESET_MODE); // attempt to detect the chip based on boot messages - std::vector airoha = {{"AG3335", "$PAIR021,AG3335", GNSS_MODEL_AG3335}, - {"AG3352", "$PAIR021,AG3352", GNSS_MODEL_AG3352}, - {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}, - {"UC6580", "UC6580", GNSS_MODEL_UC6580}, - {"L76K", "SW=URANUS", GNSS_MODEL_MTK}}; + std::vector airoha = { + {"AG3335", "$PAIR021,AG3335", GNSS_MODEL_AG3335}, + {"AG3352", "$PAIR021,AG3352", GNSS_MODEL_AG3352}, + {"RYS3520", "$PAIR021,REYAX_RYS3520_V2", GNSS_MODEL_AG3352}, + {"UC6580", "UC6580", GNSS_MODEL_UC6580}, + // as L76K is sort of a last ditch effort, we won't attempt to detect it by startup messages for now. + /*{"L76K", "SW=URANUS", GNSS_MODEL_MTK}*/}; GnssModel_t detectedDriver = getProbeResponse(500, airoha, serialSpeed); if (detectedDriver != GNSS_MODEL_UNKNOWN) { return detectedDriver;