Skip to content

Commit 189c3df

Browse files
committed
Don't wait for ack after soft reset
- reports are that there is no ACK sent after this command for newer GPS module firmware which lead to long wait and a resent.
1 parent 7b865b9 commit 189c3df

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/gps.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,12 @@ void Gps::softResetGps() {
273273
// const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x02, 0x00}; // Cold START
274274
// we had the case where the reset took several seconds
275275
// see https://github.com/openbikesensor/OpenBikeSensorFirmware/issues/309
276-
#ifdef UBX_M6
277-
sendAndWaitForAck(UBX_MSG::CFG_RST, UBX_CFG_RST, 4, 5000);
278-
#endif
279-
#ifdef UBX_M10
280-
// Newer firmware (like M10) will not ack this message
276+
// Newer firmware (like M10 and likely also M8) will not ack this
277+
// message so we do not wait for the ACK
281278
sendUbx(UBX_MSG::CFG_RST, UBX_CFG_RST, 4);
282-
#endif
283-
handle(200);
279+
waitForData(1000);
280+
handle();
281+
log_i("Soft-RESET GPS! Done");
284282
}
285283

286284
/* There had been changes for the satellites used for SBAS
@@ -603,6 +601,17 @@ bool Gps::handle() {
603601
return gotGpsData;
604602
}
605603

604+
bool Gps::waitForData(const uint16_t timeoutMs) {
605+
if (mSerial.available() > 0) {
606+
return true;
607+
}
608+
auto end = millis() + timeoutMs;
609+
while (mSerial.available() <= 0 && millis() < end) {
610+
delay(1);
611+
}
612+
return mSerial.available() > 0;
613+
}
614+
606615
static const String STATIC_MSG_PREFIX[] = {
607616
"DBG: San Vel ", "DBG: San Pos ", "DBG: San Alt ", "NTC: ANTSTATUS=", "readGPSData", "TIMEGPS set:"
608617
};

src/gps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ class Gps {
585585
#ifdef UBX_M10
586586
bool sendCfgAndWaitForAck(enum UBX_CFG_LAYER layer, UBX_CFG_KEY_ID keyId, uint32_t value, const uint16_t timeoutMs = 200); // Only available in M10
587587
#endif
588+
bool waitForData(const uint16_t timeoutMs);
588589

589590
void parseUbxMessage();
590591

0 commit comments

Comments
 (0)