Skip to content

Commit 58623ba

Browse files
committed
GPS - Increase reliability within initial cmd sends
1 parent 8b20e27 commit 58623ba

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

src/Wippersnapper_demo.ino.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/gps/hardware.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
6565
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to build PMTK ACK response!");
6666
return false;
6767
}
68+
// Flush the RX/TX buffers before sending
69+
_hw_serial->flush();
70+
while (_hw_serial->available() > 0) {
71+
_hw_serial->read();
72+
}
6873
// Send the command to the GPS module
69-
_hw_serial->flush(); // Flush the serial buffer before sending
7074
_ada_gps->sendCommand(gps_config->commands[i]);
7175
// and wait for the corresponding response from the GPS module
7276
if (!_ada_gps->waitForSentence(msg_resp)) {
@@ -169,9 +173,13 @@ bool GPSHardware::DetectMediatek() {
169173
return false;
170174
}
171175

172-
// Query MediaTek firmware version
176+
// Clear the tx and rx buffers before sending the command
173177
_hw_serial->flush();
178+
while (_hw_serial->available() > 0) {
179+
_hw_serial->read();
180+
}
174181
_hw_serial->println(CMD_MTK_QUERY_FW);
182+
// Query MediaTek firmware version
175183
// Wait for response
176184
uint16_t timeout = 2000; // 1 second timeout
177185
while (_hw_serial->available() < MAX_NEMA_SENTENCE_LEN && timeout--) {

0 commit comments

Comments
 (0)