Skip to content

Commit

Permalink
Don't wait for ack after soft reset
Browse files Browse the repository at this point in the history
- reports are that there is no ACK sent after this command for newer GPS module firmware which lead to long wait and a resent.
  • Loading branch information
amandel committed Dec 8, 2024
1 parent 7b865b9 commit 189c3df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:"
};
Expand Down
1 change: 1 addition & 0 deletions src/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 189c3df

Please sign in to comment.