Skip to content

Commit 82c9c6a

Browse files
committed
Offline - GPS over I2C working for PA1010D, UBX MAX-M10
1 parent 4792c91 commit 82c9c6a

File tree

5 files changed

+13
-60
lines changed

5 files changed

+13
-60
lines changed

src/components/gps/controller.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,7 @@ void GPSController::update() {
120120
} */
121121

122122
// Did read period elapse?
123-
// TODO: Why is it constantly polling the GPS hardware from the config.json?
124-
// Is this a bug with setting the poll period? Print it out
125123
ulong cur_time = millis();
126-
WS_DEBUG_PRINT("drv->GetPollPeriodPrv(): ");
127-
WS_DEBUG_PRINT(drv->GetPollPeriodPrv());
128-
WS_DEBUG_PRINT(" drv->GetPollPeriod(): ");
129-
WS_DEBUG_PRINTLN(drv->GetPollPeriod());
130-
WS_DEBUG_PRINT("cur_time: ");
131-
WS_DEBUG_PRINTLN(cur_time);
132124
if (cur_time - drv->GetPollPeriodPrv() < drv->GetPollPeriod())
133125
continue; // Not yet elapsed, skip this driver
134126

@@ -145,16 +137,13 @@ void GPSController::update() {
145137
bool has_gps_event = false;
146138
while (drv->NmeaBufPop(nmea_sentence) != -1) {
147139
// Let the driver parse the NMEA sentence
148-
WS_DEBUG_PRINT("[gps] Parsing NMEA sentence: ");
149-
WS_DEBUG_PRINTLN(nmea_sentence);
150140
if (!drv->ParseNMEASentence(nmea_sentence)) {
151141
continue; // Skip this sentence if parsing failed
152142
} else {
153143
has_gps_event = true; // We have a valid NMEA sentence
154144
}
155145

156146
// Using the Model, process the NMEA sentence into a GPSEvent
157-
WS_DEBUG_PRINTLN("[gps] Processing NMEA sentence...");
158147
_gps_model->ProcessNMEASentence(nmea_sentence, drv);
159148

160149
// We did not create a GPSEvent because the NMEA sentences were not
@@ -177,13 +166,9 @@ void GPSController::update() {
177166
}
178167
} else {
179168
// Log the GPSEvent to SD card
180-
WS_DEBUG_PRINT("[gps] Logging GPSEvent to SD card...");
181-
/* if
182-
(!WsV2._sdCardV2->LogEventGps(_gps_model->GetGPSEvent())) {
183-
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to log GPSEvent to
184-
SD!"); statusLEDSolid(WS_LED_STATUS_FS_WRITE); } else {
185-
WS_DEBUG_PRINTLN("OK!");
186-
} */
169+
if (!WsV2._sdCardV2->LogEventGps(_gps_model->GetGPSEvent())) {
170+
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to log GPSEvent!");
171+
}
187172
}
188173
} else {
189174
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to encode GPSEvent!");

src/components/gps/hardware.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,6 @@ void GPSHardware::PollStoreSentences() {
542542
}
543543
} else if (_driver_type == GPS_DRV_UBLOX) {
544544
// Read from the GPS module for update_rate milliseconds
545-
// TODO: Too many calls to WS_DEBUG
546-
// TOO: Maybe just delay for update_rate instead of constantly polling the
547-
// hw serial for avability? more performant
548545
ulong update_rate = 1000 / _nmea_update_rate;
549546
ulong start_time = millis();
550547
while (millis() - start_time < update_rate) {
@@ -564,10 +561,7 @@ void GPSHardware::PollStoreSentences() {
564561
nmeaBuffer += c;
565562
// Check for end of NMEA sentence
566563
if (c == '\n') {
567-
WS_DEBUG_PRINT("[gps] GOT NMEA sentence: ");
568-
WS_DEBUG_PRINTLN(nmeaBuffer.c_str());
569564
// Push the NMEA sentence to the buffer
570-
WS_DEBUG_PRINTLN("[gps] Pushing NMEA sentence to buffer...");
571565
if (NmeaBufPush(nmeaBuffer.c_str()) != 0) {
572566
WS_DEBUG_PRINTLN(
573567
"[gps] ERROR: Unable to push NMEA sentence to buffer!");

src/components/gps/model.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -206,34 +206,6 @@ bool GPSModel::ProcessNMEASentence(char *sentence, GPSHardware *drv) {
206206
char lat_dir = drv->GetLatDir();
207207
char lon_dir = drv->GetLonDir();
208208
if (sentence[3] == 'R' && sentence[4] == 'M' && sentence[5] == 'C') {
209-
// Debug prints for Sentence variabesl
210-
WS_DEBUG_PRINTLN("[gps] Processing RMC sentence...");
211-
WS_DEBUG_PRINT("[gps] Hour: ");
212-
WS_DEBUG_PRINTLN(drv->GetHour());
213-
WS_DEBUG_PRINT("[gps] Minute: ");
214-
WS_DEBUG_PRINTLN(drv->GetMinute());
215-
WS_DEBUG_PRINT("[gps] Seconds: ");
216-
WS_DEBUG_PRINTLN(drv->GetSeconds());
217-
WS_DEBUG_PRINT("[gps] Milliseconds: ");
218-
WS_DEBUG_PRINTLN(drv->GetMilliseconds());
219-
WS_DEBUG_PRINT("[gps] Day: ");
220-
WS_DEBUG_PRINTLN(drv->GetDay());
221-
WS_DEBUG_PRINT("[gps] Month: ");
222-
WS_DEBUG_PRINTLN(drv->GetMonth());
223-
WS_DEBUG_PRINT("[gps] Year: ");
224-
WS_DEBUG_PRINTLN(drv->GetYear());
225-
WS_DEBUG_PRINT("[gps] Latitude: ");
226-
WS_DEBUG_PRINTLN(drv->GetLat());
227-
WS_DEBUG_PRINT("[gps] Latitude Direction: ");
228-
WS_DEBUG_PRINTLN(lat_dir);
229-
WS_DEBUG_PRINT("[gps] Longitude: ");
230-
WS_DEBUG_PRINTLN(drv->GetLon());
231-
WS_DEBUG_PRINT("[gps] Longitude Direction: ");
232-
WS_DEBUG_PRINTLN(lon_dir);
233-
WS_DEBUG_PRINT("[gps] Speed: ");
234-
WS_DEBUG_PRINTLN(drv->GetSpeed());
235-
WS_DEBUG_PRINT("[gps] Angle: ");
236-
WS_DEBUG_PRINTLN(drv->GetAngle());
237209
// Process RMC sentence
238210
if (!AddGpsEventRMC(datetime, drv->GetFix(), drv->GetLat(), &lat_dir,
239211
drv->GetLon(), &lon_dir, drv->GetSpeed(),

src/components/i2c/controller.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,6 @@ void I2cController::update() {
13781378

13791379
// Optionally configure the I2C MUX
13801380
uint32_t mux_channel = drv->GetMuxChannel();
1381-
WS_DEBUG_PRINTLN(mux_channel);
13821381
if (drv->HasMux())
13831382
ConfigureMuxChannel(mux_channel, drv->HasAltI2CBus());
13841383

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,10 @@ bool ws_sdcard::ParseUartAdd(JsonObject &component,
499499
// set UartDeviceType
500500
const char *device_type = component["deviceType"] | "UNKNOWN";
501501
if (strcmp(device_type, "GPS") == 0) {
502-
msg_uart_add.cfg_device.device_type = wippersnapper_uart_UartDeviceType_UART_DEVICE_TYPE_GPS;
503-
msg_uart_add.cfg_device.which_config = wippersnapper_uart_UartDeviceConfig_gps_tag;
502+
msg_uart_add.cfg_device.device_type =
503+
wippersnapper_uart_UartDeviceType_UART_DEVICE_TYPE_GPS;
504+
msg_uart_add.cfg_device.which_config =
505+
wippersnapper_uart_UartDeviceConfig_gps_tag;
504506
msg_uart_add.cfg_device.config.gps.period = component["period"] | 0.0;
505507
// TODO: We do not have parsing for GPS PMTK or UBX implemented yet
506508
// This is a minimum possible implementation
@@ -907,7 +909,6 @@ bool ws_sdcard::ParseFileConfig() {
907909
*/
908910
/**************************************************************************/
909911
bool ws_sdcard::ParseComponents(JsonArray &components) {
910-
delay(9000);
911912
if (components.isNull()) {
912913
WS_DEBUG_PRINTLN("[SD] Error: File missing required components[] array");
913914
return false;
@@ -1359,7 +1360,6 @@ bool ws_sdcard::LogEventGps(wippersnapper_gps_GPSEvent *msg_gps_event) {
13591360
// Log RMC responses
13601361
for (pb_size_t rmc_resp = 0; rmc_resp < msg_gps_event->rmc_responses_count;
13611362
rmc_resp++) {
1362-
WS_DEBUG_PRINTLN("[SD] Logging RMC response...");
13631363
// Log GPS DateTime
13641364
if (msg_gps_event->rmc_responses[rmc_resp].has_datetime) {
13651365
wippersnapper_gps_GPSDateTime gps_dt =
@@ -1376,14 +1376,15 @@ bool ws_sdcard::LogEventGps(wippersnapper_gps_GPSEvent *msg_gps_event) {
13761376
doc["lon_dir"] = msg_gps_event->rmc_responses[rmc_resp].lon_dir;
13771377
doc["speed"] = msg_gps_event->rmc_responses[rmc_resp].speed;
13781378
doc["angle"] = msg_gps_event->rmc_responses[rmc_resp].angle;
1379-
if (!LogJSONDoc(doc))
1379+
if (!LogJSONDoc(doc)) {
1380+
WS_DEBUG_PRINTLN("[SD] Error: Unable to log RMC response!");
13801381
return false;
1382+
}
13811383
}
13821384

13831385
// Log GGA responses
13841386
for (pb_size_t gga_resp = 0; gga_resp < msg_gps_event->gga_responses_count;
13851387
gga_resp++) {
1386-
WS_DEBUG_PRINTLN("[SD] Logging GGA response...");
13871388
// Log GPS DateTime
13881389
if (msg_gps_event->gga_responses[gga_resp].has_datetime) {
13891390
wippersnapper_gps_GPSDateTime gps_dt =
@@ -1403,8 +1404,10 @@ bool ws_sdcard::LogEventGps(wippersnapper_gps_GPSEvent *msg_gps_event) {
14031404
doc["hdop"] = msg_gps_event->gga_responses[gga_resp].hdop;
14041405
doc["altitude"] = msg_gps_event->gga_responses[gga_resp].altitude;
14051406
doc["geoid_height"] = msg_gps_event->gga_responses[gga_resp].geoid_height;
1406-
if (!LogJSONDoc(doc))
1407+
if (!LogJSONDoc(doc)) {
1408+
WS_DEBUG_PRINTLN("[SD] Error: Unable to log GGA response!");
14071409
return false;
1410+
}
14081411
}
14091412

14101413
return true;

0 commit comments

Comments
 (0)