Skip to content

Commit d6dbda4

Browse files
committed
GPS - Fix TwoWire not being passed properly
1 parent c499080 commit d6dbda4

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

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/tmp5gn0ambf"
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ bool GPSController::AddGPS(HardwareSerial *serial,
9292
delete gps_hw;
9393
return false;
9494
}
95+
// Required - let the GPS spit out its initial data
96+
delay(1000);
9597

9698
if (!gps_hw->Handle_GPSConfig(gps_config)) {
9799
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to configure GPS!");

src/components/gps/hardware.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
7171
// Flush the RX/TX buffers before sending
7272
_hw_serial->flush();
7373
while (_hw_serial->available() > 0) {
74-
_hw_serial->read();
74+
_hw_serial->read();
7575
}
7676
}
7777
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
@@ -80,7 +80,8 @@ bool GPSHardware::Handle_GPSConfig(wippersnapper_gps_GPSConfig *gps_config) {
8080
_ada_gps->sendCommand(gps_config->commands[i]);
8181
WS_DEBUG_PRINTLN("[gps] Command sent, waiting for response...");
8282
// and wait for the corresponding response from the GPS module
83-
if (! _ada_gps->waitForSentence(msg_resp)) {
83+
if (!_ada_gps->waitForSentence(
84+
"$PMTK705,AXN_5.1.7_3333_19020118,0027,PA1010D,1.0*76")) {
8485
WS_DEBUG_PRINT("[gps] ERROR: Failed to get response | cmd:");
8586
WS_DEBUG_PRINTLN(gps_config->commands[i]);
8687
return false;
@@ -179,16 +180,13 @@ bool GPSHardware::QueryModuleType() {
179180
if (_addr == PA1010D_I2C_ADDRESS) {
180181
WS_DEBUG_PRINT("[gps] Attempting to use PA1010D driver...");
181182
// Attempt to use Adafruit_GPS I2c interface
182-
_ada_gps = new Adafruit_GPS(_hw_serial);
183-
if (! _ada_gps->begin(_addr)) {
183+
_ada_gps = new Adafruit_GPS(_wire);
184+
if (!_ada_gps->begin(_addr)) {
184185
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to initialize Mediatek!");
185186
return false;
186187
}
187188
WS_DEBUG_PRINTLN("ok!");
188189
_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!");
192190
return true;
193191
} else {
194192
WS_DEBUG_PRINTLN(

src/components/i2c/controller.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,6 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
967967
WS_DEBUG_PRINTLN("OK!");
968968
} else if (is_gps) {
969969
WS_DEBUG_PRINT("[i2c] Creating a GPS driver...");
970-
// TODO: You were here!
971-
// bool GPSController::AddGPS(TwoWire *wire, uint32_t i2c_addr, wippersnapper_gps_GPSConfig *gps_config) {
972970
if (!WsV2._gps_controller->AddGPS(bus, device_descriptor.i2c_device_address, &_i2c_model->GetI2cDeviceAddOrReplaceMsg()->gps_config)) {
973971
did_init = false;
974972
WS_DEBUG_PRINTLN("FAILURE!");

0 commit comments

Comments
 (0)