Skip to content

Commit c499080

Browse files
committed
GPS - handleConfig not working yet, paused on validation
1 parent 320fa1e commit c499080

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/components/gps/hardware.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,28 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
5959
// TODO: We may want to break this out into a generic function that supports
6060
// MTK, Ublox, etc...
6161
for (size_t i = 0; i < gps_config->commands_count; i++) {
62-
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
63-
WS_DEBUG_PRINTLN(gps_config->commands[i]);
6462
// Build the PMTK ACK response for the command
6563
char msg_resp[MAX_NEMA_SENTENCE_LEN];
64+
WS_DEBUG_PRINT("[gps] Building PMTK ACK response for command: ");
6665
if (!BuildPmtkAck(gps_config->commands[i], msg_resp)) {
6766
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to build PMTK ACK response!");
6867
return false;
6968
}
70-
// Flush the RX/TX buffers before sending
71-
_hw_serial->flush();
72-
while (_hw_serial->available() > 0) {
73-
_hw_serial->read();
69+
WS_DEBUG_PRINTLN(msg_resp);
70+
if (_iface_type == GPS_IFACE_UART_HW) {
71+
// Flush the RX/TX buffers before sending
72+
_hw_serial->flush();
73+
while (_hw_serial->available() > 0) {
74+
_hw_serial->read();
75+
}
7476
}
77+
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
78+
WS_DEBUG_PRINTLN(gps_config->commands[i]);
7579
// Send the command to the GPS module
7680
_ada_gps->sendCommand(gps_config->commands[i]);
81+
WS_DEBUG_PRINTLN("[gps] Command sent, waiting for response...");
7782
// and wait for the corresponding response from the GPS module
78-
if (!_ada_gps->waitForSentence(msg_resp)) {
83+
if (! _ada_gps->waitForSentence(msg_resp)) {
7984
WS_DEBUG_PRINT("[gps] ERROR: Failed to get response | cmd:");
8085
WS_DEBUG_PRINTLN(gps_config->commands[i]);
8186
return false;
@@ -175,12 +180,15 @@ bool GPSHardware::QueryModuleType() {
175180
WS_DEBUG_PRINT("[gps] Attempting to use PA1010D driver...");
176181
// Attempt to use Adafruit_GPS I2c interface
177182
_ada_gps = new Adafruit_GPS(_hw_serial);
178-
if (!_ada_gps->begin(_addr)) {
183+
if (! _ada_gps->begin(_addr)) {
179184
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to initialize Mediatek!");
180185
return false;
181186
}
182187
WS_DEBUG_PRINTLN("ok!");
183188
_driver_type = GPS_DRV_MTK;
189+
WS_DEBUG_PRINT("sending RMCGGA...");
190+
_ada_gps->sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
191+
WS_DEBUG_PRINTLN("Sent command!");
184192
return true;
185193
} else {
186194
WS_DEBUG_PRINTLN(

0 commit comments

Comments
 (0)