Skip to content

Commit 3d969cf

Browse files
committed
Offline/SD - UART GPS, UART US-100 OK
1 parent 82c9c6a commit 3d969cf

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

src/Wippersnapper_demo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ws_adapter_wifi wipper;
1515

1616
void setup() {
1717
Serial.begin(115200);
18-
while (!Serial) delay(10);
18+
while(!Serial);
1919
wipper.provision();
2020
wipper.connect();
2121
}

src/components/gps/hardware.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,12 @@ bool GPSHardware::DetectMtkUart() {
323323
while (_hw_serial->available() > 0) {
324324
_hw_serial->read();
325325
}
326-
_hw_serial->println(CMD_MTK_QUERY_FW);
326+
327327
// Query MediaTek firmware version
328-
// Wait for response
329-
uint16_t timeout = 2000; // 1 second timeout
328+
uint16_t timeout = MTK_QUERY_FW_TIMEOUT;
330329
while (_hw_serial->available() < MAX_NEMA_SENTENCE_LEN && timeout--) {
331330
delay(1);
332331
}
333-
334332
if (timeout == 0)
335333
return false;
336334

src/components/gps/hardware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define CMD_MTK_QUERY_FW_RESP \
2525
"$PMTK705" ///< Response from querying MediaTek firmware version without the
2626
///< ReleaseStr
27+
#define MTK_QUERY_FW_TIMEOUT 2000 ///< Timeout for MediaTek firmware query in ms
2728
#define CMD_MTK_CHECK_ANTENNA "$PGCMD,33,1*6C" ///< Command to check antenna
2829
#define DEFAULT_MTK_NMEA_UPDATE_RATE 1 ///< Default NMEA update rate in Hz
2930
#define DEFAULT_MTK_NMEA_BAUD_RATE 9600 ///< Default NMEA baud rate in bits per

src/components/uart/controller.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ bool UARTController::Handle_UartAdd(pb_istream_t *stream) {
7474
GPSController *drv_uart_gps = nullptr;
7575
bool is_gps_drv = false;
7676
wippersnapper_uart_UartDeviceConfig cfg_device = add_msg->cfg_device;
77+
WS_DEBUG_PRINT("[UART DEBUG] cfg_device.device_type: ");
78+
WS_DEBUG_PRINTLN(cfg_device.device_type);
7779
switch (cfg_device.device_type) {
7880
case wippersnapper_uart_UartDeviceType_UART_DEVICE_TYPE_UNSPECIFIED:
7981
WS_DEBUG_PRINTLN("[uart] ERROR: Unspecified device type!");

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,13 @@ uint32_t ws_sdcard::HexStrToInt(const char *hex_str) {
474474
*/
475475
bool ws_sdcard::ParseUartAdd(JsonObject &component,
476476
wippersnapper_uart_UartAdd &msg_uart_add) {
477+
delay(5500);
477478
// Configure the Serial
478479
msg_uart_add.has_cfg_serial = true;
479-
strncpy(msg_uart_add.cfg_serial.pin_rx, component["pinRx"] | UNKNOWN_VALUE,
480-
sizeof(msg_uart_add.cfg_serial.pin_rx) - 1);
481-
strncpy(msg_uart_add.cfg_serial.pin_tx, component["pinTx"] | UNKNOWN_VALUE,
482-
sizeof(msg_uart_add.cfg_serial.pin_tx) - 1);
480+
snprintf(msg_uart_add.cfg_serial.pin_rx, sizeof(msg_uart_add.cfg_serial.pin_rx),
481+
"%d", component["pinRx"] | -1);
482+
snprintf(msg_uart_add.cfg_serial.pin_tx, sizeof(msg_uart_add.cfg_serial.pin_tx),
483+
"%d", component["pinTx"] | -1);
483484
msg_uart_add.cfg_serial.uart_nbr = component["uartNbr"] | 0;
484485
msg_uart_add.cfg_serial.baud_rate = component["baudRate"] | 9600;
485486
msg_uart_add.cfg_serial.format =
@@ -1426,10 +1427,16 @@ bool ws_sdcard::LogEventUart(
14261427
doc["uart_device_id"] = msg_uart_input_event->device_id;
14271428
doc["uart_port"] = msg_uart_input_event->uart_nbr;
14281429

1430+
WS_DEBUG_PRINT("UART Events: ");
1431+
WS_DEBUG_PRINTLN(msg_uart_input_event->events_count);
14291432
// Log each event
14301433
for (pb_size_t i = 0; i < msg_uart_input_event->events_count; i++) {
14311434
doc["value"] = msg_uart_input_event->events[i].value.float_value;
14321435
doc["si_unit"] = SensorTypeToSIUnit(msg_uart_input_event->events[i].type);
1436+
WS_DEBUG_PRINT("Logging UART Event: ");
1437+
WS_DEBUG_PRINTLN(doc["value"].as<float>());
1438+
WS_DEBUG_PRINT("SI Unit: ");
1439+
WS_DEBUG_PRINTLN(doc["si_unit"].as<const char *>());
14331440
}
14341441

14351442
if (!LogJSONDoc(doc))

0 commit comments

Comments
 (0)