Skip to content

Commit f05f163

Browse files
committed
GPS - Build checksum for responses
1 parent de6a1dd commit f05f163

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

src/Wippersnapper_V2.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,5 @@ ws_status_t Wippersnapper_V2::run() {
13741374
// Process UART driver events
13751375
WsV2._uart_controller->update();
13761376

1377-
// Process GPS events
1378-
// TODO!
1379-
// WsV2._gps_controller->update();
1380-
13811377
return WS_NET_CONNECTED; // TODO: Make this funcn void!
13821378
}

src/Wippersnapper_demo.ino.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmp66ayxrmc"
2+
#include <Arduino.h>
3+
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
4+
# 11 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
5+
#include "ws_adapters.h"
6+
ws_adapter_wifi wipper;
7+
8+
9+
#define WS_DEBUG
10+
void setup();
11+
void loop();
12+
#line 17 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
13+
void setup() {
14+
Serial.begin(115200);
15+
while (!Serial)
16+
delay(10);
17+
wipper.provision();
18+
wipper.connect();
19+
}
20+
21+
void loop() { wipper.run(); }

src/components/gps/controller.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,28 @@ bool GPSController::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
6060
for (size_t i = 0; i < gps_config->commands_count; i++) {
6161
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
6262
WS_DEBUG_PRINTLN(gps_config->commands[i]);
63-
_hw_serial->flush(); // Flush the serial buffer before sending
63+
64+
// Build the ACK command
65+
// first, strip out the command number only from the command string
66+
int cmd_num = 0;
67+
if (sscanf(gps_config->commands[i], "$PMTK%d", &cmd_num) == 1) {
68+
WS_DEBUG_PRINT("[gps] Command number extracted: ");
69+
WS_DEBUG_PRINTLN(cmd_num);
70+
} else {
71+
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to extract command number!");
72+
return false;
73+
}
74+
char cmd_resp[255];
75+
snprintf(cmd_resp, sizeof(cmd_resp), "$PMTK001,%d,3", cmd_num);
76+
_ada_gps->addChecksum(cmd_resp);
77+
WS_DEBUG_PRINT("[gps] ACK command w/checksum: ");
78+
WS_DEBUG_PRINTLN(cmd_resp);
79+
6480
// Send the command to the GPS module
81+
_hw_serial->flush(); // Flush the serial buffer before sending
6582
_ada_gps->sendCommand(gps_config->commands[i]);
6683
// and wait for the corresponding response from the GPS module
67-
if (!_ada_gps->waitForSentence(gps_config->responses[i])) {
84+
if (!_ada_gps->waitForSentence(cmd_resp)) {
6885
WS_DEBUG_PRINT(
6986
"[gps] ERROR: Failed to get response from MediaTek for cmd:");
7087
WS_DEBUG_PRINTLN(gps_config->commands[i]);

0 commit comments

Comments
 (0)