@@ -59,23 +59,28 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
59
59
// TODO: We may want to break this out into a generic function that supports
60
60
// MTK, Ublox, etc...
61
61
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]);
64
62
// Build the PMTK ACK response for the command
65
63
char msg_resp[MAX_NEMA_SENTENCE_LEN];
64
+ WS_DEBUG_PRINT (" [gps] Building PMTK ACK response for command: " );
66
65
if (!BuildPmtkAck (gps_config->commands [i], msg_resp)) {
67
66
WS_DEBUG_PRINTLN (" [gps] ERROR: Failed to build PMTK ACK response!" );
68
67
return false ;
69
68
}
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
+ }
74
76
}
77
+ WS_DEBUG_PRINT (" [gps] Sending command to MediaTek GPS: " );
78
+ WS_DEBUG_PRINTLN (gps_config->commands [i]);
75
79
// Send the command to the GPS module
76
80
_ada_gps->sendCommand (gps_config->commands [i]);
81
+ WS_DEBUG_PRINTLN (" [gps] Command sent, waiting for response..." );
77
82
// and wait for the corresponding response from the GPS module
78
- if (!_ada_gps->waitForSentence (msg_resp)) {
83
+ if (! _ada_gps->waitForSentence (msg_resp)) {
79
84
WS_DEBUG_PRINT (" [gps] ERROR: Failed to get response | cmd:" );
80
85
WS_DEBUG_PRINTLN (gps_config->commands [i]);
81
86
return false ;
@@ -175,12 +180,15 @@ bool GPSHardware::QueryModuleType() {
175
180
WS_DEBUG_PRINT (" [gps] Attempting to use PA1010D driver..." );
176
181
// Attempt to use Adafruit_GPS I2c interface
177
182
_ada_gps = new Adafruit_GPS (_hw_serial);
178
- if (!_ada_gps->begin (_addr)) {
183
+ if (! _ada_gps->begin (_addr)) {
179
184
WS_DEBUG_PRINTLN (" [gps] ERROR: Failed to initialize Mediatek!" );
180
185
return false ;
181
186
}
182
187
WS_DEBUG_PRINTLN (" ok!" );
183
188
_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!" );
184
192
return true ;
185
193
} else {
186
194
WS_DEBUG_PRINTLN (
0 commit comments