@@ -628,7 +628,8 @@ bool ws_sdcard::ParseI2cDeviceAddReplace(
628
628
WS_DEBUG_PRINTLN (is_gps ? " true" : " false" );
629
629
if (is_gps) {
630
630
msg_i2c_add.is_gps = true ;
631
- msg_i2c_add.has_gps_config = false ; // TODO: Set to true!
631
+ msg_i2c_add.gps_config .period = component[" period" ] | 15.0 ;
632
+ msg_i2c_add.has_gps_config = true ;
632
633
return true ; // early-out, we don't need to set sensor types for GPS
633
634
}
634
635
@@ -903,6 +904,7 @@ bool ws_sdcard::ParseFileConfig() {
903
904
*/
904
905
/* *************************************************************************/
905
906
bool ws_sdcard::ParseComponents (JsonArray &components) {
907
+ delay (9000 );
906
908
if (components.isNull ()) {
907
909
WS_DEBUG_PRINTLN (" [SD] Error: File missing required components[] array" );
908
910
return false ;
@@ -1229,8 +1231,8 @@ bool ws_sdcard::LogJSONDoc(JsonDocument &doc) {
1229
1231
@returns True if the event was successfully logged, False otherwise.
1230
1232
*/
1231
1233
/* *************************************************************************/
1232
- bool ws_sdcard::LogGPIOSensorEventToSD (
1233
- uint8_t pin, float value, wippersnapper_sensor_SensorType read_type) {
1234
+ bool ws_sdcard::LogEventGpio ( uint8_t pin, float value,
1235
+ wippersnapper_sensor_SensorType read_type) {
1234
1236
JsonDocument doc;
1235
1237
BuildJSONDoc (doc, pin, value, read_type);
1236
1238
if (!LogJSONDoc (doc))
@@ -1250,8 +1252,8 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
1250
1252
@returns True if the event was successfully logged, False otherwise.
1251
1253
*/
1252
1254
/* *************************************************************************/
1253
- bool ws_sdcard::LogGPIOSensorEventToSD (
1254
- uint8_t pin, uint16_t value, wippersnapper_sensor_SensorType read_type) {
1255
+ bool ws_sdcard::LogEventGpio ( uint8_t pin, uint16_t value,
1256
+ wippersnapper_sensor_SensorType read_type) {
1255
1257
JsonDocument doc;
1256
1258
BuildJSONDoc (doc, pin, value, read_type);
1257
1259
if (!LogJSONDoc (doc))
@@ -1271,8 +1273,8 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
1271
1273
@returns True if the event was successfully logged, False otherwise.
1272
1274
*/
1273
1275
/* *************************************************************************/
1274
- bool ws_sdcard::LogGPIOSensorEventToSD (
1275
- uint8_t pin, bool value, wippersnapper_sensor_SensorType read_type) {
1276
+ bool ws_sdcard::LogEventGpio ( uint8_t pin, bool value,
1277
+ wippersnapper_sensor_SensorType read_type) {
1276
1278
JsonDocument doc;
1277
1279
BuildJSONDoc (doc, pin, value, read_type);
1278
1280
if (!LogJSONDoc (doc))
@@ -1292,8 +1294,7 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
1292
1294
@returns True if the event was successfully logged, False otherwise.
1293
1295
*/
1294
1296
/* *************************************************************************/
1295
- bool ws_sdcard::LogDS18xSensorEventToSD (
1296
- wippersnapper_ds18x20_Ds18x20Event *event_msg) {
1297
+ bool ws_sdcard::LogEventDs18x (wippersnapper_ds18x20_Ds18x20Event *event_msg) {
1297
1298
JsonDocument doc;
1298
1299
// Iterate over the event message's sensor events
1299
1300
// TODO: Standardize this Event with I2C
@@ -1314,7 +1315,7 @@ bool ws_sdcard::LogDS18xSensorEventToSD(
1314
1315
The I2cDeviceEvent message to log.
1315
1316
@returns True if the event was successfully logged, False otherwise.
1316
1317
*/
1317
- bool ws_sdcard::LogI2cDeviceEvent (
1318
+ bool ws_sdcard::LogEventI2c (
1318
1319
wippersnapper_i2c_I2cDeviceEvent *msg_device_event) {
1319
1320
JsonDocument doc;
1320
1321
// Pull the DeviceDescriptor out
@@ -1349,56 +1350,85 @@ bool ws_sdcard::LogI2cDeviceEvent(
1349
1350
The GPSEvent message to log.
1350
1351
@returns True if the event was successfully logged, False otherwise.
1351
1352
*/
1352
- bool ws_sdcard::LogGPSEventToSD (wippersnapper_gps_GPSEvent *msg_gps_event) {
1353
- JsonDocument doc;
1354
-
1355
- // Log RMC responses
1356
- for (pb_size_t rmc_resp = 0 ; rmc_resp < msg_gps_event->rmc_responses_count ; rmc_resp++) {
1357
- WS_DEBUG_PRINTLN (" [SD] Logging RMC response..." );
1358
- // Log GPS DateTime
1359
- if (msg_gps_event->rmc_responses [rmc_resp].has_datetime ) {
1360
- wippersnapper_gps_GPSDateTime gps_dt = msg_gps_event->rmc_responses [rmc_resp].datetime ;
1361
- DateTime gps_datetime (gps_dt.year , gps_dt.month , gps_dt.day ,
1362
- gps_dt.hour , gps_dt.minute , gps_dt.seconds );
1363
- doc[" timestamp" ] = gps_datetime.unixtime ();
1364
- }
1365
- // Log GPS data
1366
- doc[" fix_status" ] = msg_gps_event->rmc_responses [rmc_resp].fix_status ;
1367
- doc[" latitude" ] = msg_gps_event->rmc_responses [rmc_resp].lat ;
1368
- doc[" lat_dir" ] = msg_gps_event->rmc_responses [rmc_resp].lat_dir ;
1369
- doc[" longitude" ] = msg_gps_event->rmc_responses [rmc_resp].lon ;
1370
- doc[" lon_dir" ] = msg_gps_event->rmc_responses [rmc_resp].lon_dir ;
1371
- doc[" speed" ] = msg_gps_event->rmc_responses [rmc_resp].speed ;
1372
- doc[" angle" ] = msg_gps_event->rmc_responses [rmc_resp].angle ;
1373
- if (!LogJSONDoc (doc))
1374
- return false ;
1353
+ bool ws_sdcard::LogEventGps (wippersnapper_gps_GPSEvent *msg_gps_event) {
1354
+ JsonDocument doc;
1355
+
1356
+ // Log RMC responses
1357
+ for (pb_size_t rmc_resp = 0 ; rmc_resp < msg_gps_event->rmc_responses_count ;
1358
+ rmc_resp++) {
1359
+ WS_DEBUG_PRINTLN (" [SD] Logging RMC response..." );
1360
+ // Log GPS DateTime
1361
+ if (msg_gps_event->rmc_responses [rmc_resp].has_datetime ) {
1362
+ wippersnapper_gps_GPSDateTime gps_dt =
1363
+ msg_gps_event->rmc_responses [rmc_resp].datetime ;
1364
+ DateTime gps_datetime (gps_dt.year , gps_dt.month , gps_dt.day , gps_dt.hour ,
1365
+ gps_dt.minute , gps_dt.seconds );
1366
+ doc[" timestamp" ] = gps_datetime.unixtime ();
1375
1367
}
1368
+ // Log GPS data
1369
+ doc[" fix_status" ] = msg_gps_event->rmc_responses [rmc_resp].fix_status ;
1370
+ doc[" latitude" ] = msg_gps_event->rmc_responses [rmc_resp].lat ;
1371
+ doc[" lat_dir" ] = msg_gps_event->rmc_responses [rmc_resp].lat_dir ;
1372
+ doc[" longitude" ] = msg_gps_event->rmc_responses [rmc_resp].lon ;
1373
+ doc[" lon_dir" ] = msg_gps_event->rmc_responses [rmc_resp].lon_dir ;
1374
+ doc[" speed" ] = msg_gps_event->rmc_responses [rmc_resp].speed ;
1375
+ doc[" angle" ] = msg_gps_event->rmc_responses [rmc_resp].angle ;
1376
+ if (!LogJSONDoc (doc))
1377
+ return false ;
1378
+ }
1376
1379
1377
- // Log GGA responses
1378
- for (pb_size_t gga_resp = 0 ; gga_resp < msg_gps_event->gga_responses_count ; gga_resp++) {
1379
- WS_DEBUG_PRINTLN (" [SD] Logging GGA response..." );
1380
- // Log GPS DateTime
1381
- if (msg_gps_event->gga_responses [gga_resp].has_datetime ) {
1382
- wippersnapper_gps_GPSDateTime gps_dt = msg_gps_event->gga_responses [gga_resp].datetime ;
1383
- DateTime gps_datetime (gps_dt.year , gps_dt.month , gps_dt.day ,
1384
- gps_dt.hour , gps_dt.minute , gps_dt.seconds );
1385
- doc[" timestamp" ] = gps_datetime.unixtime ();
1386
- }
1387
- // Log GPS data
1388
- doc[" latitude" ] = msg_gps_event->gga_responses [gga_resp].lat ;
1389
- doc[" lat_dir" ] = msg_gps_event->gga_responses [gga_resp].lat_dir ;
1390
- doc[" longitude" ] = msg_gps_event->gga_responses [gga_resp].lon ;
1391
- doc[" lon_dir" ] = msg_gps_event->gga_responses [gga_resp].lon_dir ;
1392
- doc[" fix_quality" ] = msg_gps_event->gga_responses [gga_resp].fix_quality ;
1393
- doc[" num_satellites" ] = msg_gps_event->gga_responses [gga_resp].num_satellites ;
1394
- doc[" hdop" ] = msg_gps_event->gga_responses [gga_resp].hdop ;
1395
- doc[" altitude" ] = msg_gps_event->gga_responses [gga_resp].altitude ;
1396
- doc[" geoid_height" ] = msg_gps_event->gga_responses [gga_resp].geoid_height ;
1397
- if (!LogJSONDoc (doc))
1398
- return false ;
1380
+ // Log GGA responses
1381
+ for (pb_size_t gga_resp = 0 ; gga_resp < msg_gps_event->gga_responses_count ;
1382
+ gga_resp++) {
1383
+ WS_DEBUG_PRINTLN (" [SD] Logging GGA response..." );
1384
+ // Log GPS DateTime
1385
+ if (msg_gps_event->gga_responses [gga_resp].has_datetime ) {
1386
+ wippersnapper_gps_GPSDateTime gps_dt =
1387
+ msg_gps_event->gga_responses [gga_resp].datetime ;
1388
+ DateTime gps_datetime (gps_dt.year , gps_dt.month , gps_dt.day , gps_dt.hour ,
1389
+ gps_dt.minute , gps_dt.seconds );
1390
+ doc[" timestamp" ] = gps_datetime.unixtime ();
1399
1391
}
1392
+ // Log GPS data
1393
+ doc[" latitude" ] = msg_gps_event->gga_responses [gga_resp].lat ;
1394
+ doc[" lat_dir" ] = msg_gps_event->gga_responses [gga_resp].lat_dir ;
1395
+ doc[" longitude" ] = msg_gps_event->gga_responses [gga_resp].lon ;
1396
+ doc[" lon_dir" ] = msg_gps_event->gga_responses [gga_resp].lon_dir ;
1397
+ doc[" fix_quality" ] = msg_gps_event->gga_responses [gga_resp].fix_quality ;
1398
+ doc[" num_satellites" ] =
1399
+ msg_gps_event->gga_responses [gga_resp].num_satellites ;
1400
+ doc[" hdop" ] = msg_gps_event->gga_responses [gga_resp].hdop ;
1401
+ doc[" altitude" ] = msg_gps_event->gga_responses [gga_resp].altitude ;
1402
+ doc[" geoid_height" ] = msg_gps_event->gga_responses [gga_resp].geoid_height ;
1403
+ if (!LogJSONDoc (doc))
1404
+ return false ;
1405
+ }
1406
+
1407
+ return true ;
1408
+ }
1409
+
1410
+ /* !
1411
+ @brief Logs a UART input event to the SD card.
1412
+ @param msg_uart_input_event
1413
+ The UartInputEvent message to log.
1414
+ @returns True if the event was successfully logged, False otherwise.
1415
+ */
1416
+ bool ws_sdcard::LogEventUart (
1417
+ wippersnapper_uart_UartInputEvent *msg_uart_input_event) {
1418
+ JsonDocument doc;
1419
+ doc[" timestamp" ] = GetTimestamp ();
1420
+ doc[" uart_device_id" ] = msg_uart_input_event->device_id ;
1421
+ doc[" uart_port" ] = msg_uart_input_event->uart_nbr ;
1422
+
1423
+ // Log each event
1424
+ for (pb_size_t i = 0 ; i < msg_uart_input_event->events_count ; i++) {
1425
+ doc[" value" ] = msg_uart_input_event->events [i].value .float_value ;
1426
+ doc[" si_unit" ] = SensorTypeToSIUnit (msg_uart_input_event->events [i].type );
1427
+ }
1400
1428
1401
- return true ;
1429
+ if (!LogJSONDoc (doc))
1430
+ return false ;
1431
+ return true ;
1402
1432
}
1403
1433
1404
1434
#ifdef OFFLINE_MODE_DEBUG
0 commit comments