Skip to content

Commit c9d9595

Browse files
committed
GPS - Remove redundant delay, update BuildPmtkAck() func
1 parent 07f936c commit c9d9595

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

src/Wippersnapper_demo.ino.cpp

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

src/components/gps/hardware.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,17 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
6868
return false;
6969
}
7070

71-
// Delay for two seconds to allow the GPS module to initialize
72-
WS_DEBUG_PRINTLN("[gps] Delaying for 1 second");
73-
delay(1000);
7471
// Iterate through the command sentences and send them to the GPS module
7572
// TODO: We may want to break this out into a generic function that supports
7673
// MTK, Ublox, etc...
7774
for (size_t i = 0; i < gps_config->commands_count; i++) {
7875
// Build the PMTK ACK response for the command
7976
char msg_resp[MAX_NEMA_SENTENCE_LEN];
80-
WS_DEBUG_PRINT("[gps] Building PMTK ACK response: ");
8177
if (!BuildPmtkAck(gps_config->commands[i], msg_resp)) {
8278
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to build PMTK ACK response!");
8379
return false;
8480
}
81+
WS_DEBUG_PRINT("[gps] Expected response: ");
8582
WS_DEBUG_PRINTLN(msg_resp);
8683
if (_iface_type == GPS_IFACE_UART_HW) {
8784
// Flush the RX/TX buffers before sending
@@ -90,13 +87,15 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
9087
_hw_serial->read();
9188
}
9289
} else if (_iface_type == GPS_IFACE_I2C) {
90+
WS_DEBUG_PRINT("[gps] Flushing I2C buffers...");
9391
I2cReadDiscard();
92+
WS_DEBUG_PRINTLN(" done!");
9493
}
95-
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
94+
WS_DEBUG_PRINT("[gps] TX, CMD: ");
9695
WS_DEBUG_PRINTLN(gps_config->commands[i]);
9796
// Send the command to the GPS module
9897
_ada_gps->sendCommand(gps_config->commands[i]);
99-
WS_DEBUG_PRINTLN("[gps] Command sent, waiting for response...");
98+
WS_DEBUG_PRINTLN("[gps] Waiting for RX...");
10099
// and wait for the corresponding response from the GPS module
101100
if (!_ada_gps->waitForSentence(msg_resp, 255)) {
102101
WS_DEBUG_PRINT("[gps] ERROR: Failed to get response | cmd:");
@@ -288,7 +287,6 @@ bool GPSHardware::BuildPmtkAck(char *msg_cmd, char *msg_resp) {
288287
if (sscanf(msg_cmd, "$PMTK%d", &cmd_num) != 1)
289288
return false;
290289
snprintf(msg_resp, MAX_NEMA_SENTENCE_LEN, "$PMTK001,%d,3", cmd_num);
291-
_ada_gps->addChecksum(msg_resp);
292290
return true;
293291
}
294292

0 commit comments

Comments
 (0)