@@ -628,7 +628,8 @@ bool ws_sdcard::ParseI2cDeviceAddReplace(
628628 WS_DEBUG_PRINTLN (is_gps ? " true" : " false" );
629629 if (is_gps) {
630630 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 ;
632633 return true ; // early-out, we don't need to set sensor types for GPS
633634 }
634635
@@ -903,6 +904,7 @@ bool ws_sdcard::ParseFileConfig() {
903904*/
904905/* *************************************************************************/
905906bool ws_sdcard::ParseComponents (JsonArray &components) {
907+ delay (9000 );
906908 if (components.isNull ()) {
907909 WS_DEBUG_PRINTLN (" [SD] Error: File missing required components[] array" );
908910 return false ;
@@ -1229,8 +1231,8 @@ bool ws_sdcard::LogJSONDoc(JsonDocument &doc) {
12291231 @returns True if the event was successfully logged, False otherwise.
12301232*/
12311233/* *************************************************************************/
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) {
12341236 JsonDocument doc;
12351237 BuildJSONDoc (doc, pin, value, read_type);
12361238 if (!LogJSONDoc (doc))
@@ -1250,8 +1252,8 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
12501252 @returns True if the event was successfully logged, False otherwise.
12511253*/
12521254/* *************************************************************************/
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) {
12551257 JsonDocument doc;
12561258 BuildJSONDoc (doc, pin, value, read_type);
12571259 if (!LogJSONDoc (doc))
@@ -1271,8 +1273,8 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
12711273 @returns True if the event was successfully logged, False otherwise.
12721274*/
12731275/* *************************************************************************/
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) {
12761278 JsonDocument doc;
12771279 BuildJSONDoc (doc, pin, value, read_type);
12781280 if (!LogJSONDoc (doc))
@@ -1292,8 +1294,7 @@ bool ws_sdcard::LogGPIOSensorEventToSD(
12921294 @returns True if the event was successfully logged, False otherwise.
12931295*/
12941296/* *************************************************************************/
1295- bool ws_sdcard::LogDS18xSensorEventToSD (
1296- wippersnapper_ds18x20_Ds18x20Event *event_msg) {
1297+ bool ws_sdcard::LogEventDs18x (wippersnapper_ds18x20_Ds18x20Event *event_msg) {
12971298 JsonDocument doc;
12981299 // Iterate over the event message's sensor events
12991300 // TODO: Standardize this Event with I2C
@@ -1314,7 +1315,7 @@ bool ws_sdcard::LogDS18xSensorEventToSD(
13141315 The I2cDeviceEvent message to log.
13151316 @returns True if the event was successfully logged, False otherwise.
13161317*/
1317- bool ws_sdcard::LogI2cDeviceEvent (
1318+ bool ws_sdcard::LogEventI2c (
13181319 wippersnapper_i2c_I2cDeviceEvent *msg_device_event) {
13191320 JsonDocument doc;
13201321 // Pull the DeviceDescriptor out
@@ -1349,56 +1350,85 @@ bool ws_sdcard::LogI2cDeviceEvent(
13491350 The GPSEvent message to log.
13501351 @returns True if the event was successfully logged, False otherwise.
13511352*/
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 ();
13751367 }
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+ }
13761379
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 ();
13991391 }
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+ }
14001428
1401- return true ;
1429+ if (!LogJSONDoc (doc))
1430+ return false ;
1431+ return true ;
14021432}
14031433
14041434#ifdef OFFLINE_MODE_DEBUG
0 commit comments