diff --git a/src/gps.cpp b/src/gps.cpp index 0d377c7..b52d4e5 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -273,14 +273,12 @@ void Gps::softResetGps() { // const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x02, 0x00}; // Cold START // we had the case where the reset took several seconds // see https://github.com/openbikesensor/OpenBikeSensorFirmware/issues/309 -#ifdef UBX_M6 - sendAndWaitForAck(UBX_MSG::CFG_RST, UBX_CFG_RST, 4, 5000); -#endif -#ifdef UBX_M10 - // Newer firmware (like M10) will not ack this message + // Newer firmware (like M10 and likely also M8) will not ack this + // message so we do not wait for the ACK sendUbx(UBX_MSG::CFG_RST, UBX_CFG_RST, 4); -#endif - handle(200); + waitForData(1000); + handle(); + log_i("Soft-RESET GPS! Done"); } /* There had been changes for the satellites used for SBAS @@ -603,6 +601,17 @@ bool Gps::handle() { return gotGpsData; } +bool Gps::waitForData(const uint16_t timeoutMs) { + if (mSerial.available() > 0) { + return true; + } + auto end = millis() + timeoutMs; + while (mSerial.available() <= 0 && millis() < end) { + delay(1); + } + return mSerial.available() > 0; +} + static const String STATIC_MSG_PREFIX[] = { "DBG: San Vel ", "DBG: San Pos ", "DBG: San Alt ", "NTC: ANTSTATUS=", "readGPSData", "TIMEGPS set:" }; diff --git a/src/gps.h b/src/gps.h index 0c4f908..d660ae8 100644 --- a/src/gps.h +++ b/src/gps.h @@ -585,6 +585,7 @@ class Gps { #ifdef UBX_M10 bool sendCfgAndWaitForAck(enum UBX_CFG_LAYER layer, UBX_CFG_KEY_ID keyId, uint32_t value, const uint16_t timeoutMs = 200); // Only available in M10 #endif + bool waitForData(const uint16_t timeoutMs); void parseUbxMessage();