@@ -305,30 +305,43 @@ bool ws_sdcard::parseConfigFile() {
305305 return false ;
306306 }
307307
308+ WS_DEBUG_PRINT (" [SD] msg_DS18X20Add.sensor_types_count: " );
309+ WS_DEBUG_PRINTLN (msg_DS18X20Add.sensor_types_count );
310+
308311 // Parse the sensor types into the DS18X20Add message
309312 // TODO: This structor needs a refactoring pass! It's too confusing
310- if (msg_DS18X20Add.sensor_types_count == 1 ) {
311- if (component[" sensorType1" ] != nullptr ) {
312- msg_DS18X20Add.sensor_types [0 ] = component[" sensorType1" ];
313+ if (msg_DS18X20Add.sensor_types_count == 1 ||
314+ msg_DS18X20Add.sensor_types_count == 2 ) {
315+ if (strcmp (component[" sensorType1" ], " ambient-temp-fahrenheit" ) == 0 ) {
316+ msg_DS18X20Add.sensor_types [0 ] =
317+ wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT;
318+ } else if (strcmp (component[" sensorType1" ], " ambient-temp" ) == 0 ) {
319+ msg_DS18X20Add.sensor_types [0 ] =
320+ wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE;
313321 } else {
314- WS_DEBUG_PRINTLN (" [SD] FATAL Parsing error - No sensor type found in "
315- " JSON string!" );
322+ WS_DEBUG_PRINTLN (
323+ " [SD] FATAL Parsing error - Unsupported ds18x sensor "
324+ " type found in JSON!" );
316325 return false ;
317326 }
318- } else if (msg_DS18X20Add.sensor_types_count == 2 ) {
319- if (component[" sensorType1" ] != nullptr &&
320- component[" sensorType2" ] != nullptr ) {
321- msg_DS18X20Add.sensor_types [0 ] = component[" sensorType1" ];
322- msg_DS18X20Add.sensor_types [1 ] = component[" sensorType2" ];
323- } else {
324- WS_DEBUG_PRINTLN (" [SD] FATAL Parsing error - No sensor type found in "
325- " JSON string!" );
326- return false ;
327+ }
328+ if (msg_DS18X20Add.sensor_types_count == 2 ) {
329+ WS_DEBUG_PRINTLN (" [SD] Parsing sensor type 2..." );
330+ if (component[" sensorType2" ] != nullptr ) {
331+ if (strcmp (component[" sensorType2" ], " ambient-temp-fahrenheit" ) ==
332+ 0 ) {
333+ msg_DS18X20Add.sensor_types [1 ] =
334+ wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT;
335+ } else if (strcmp (component[" sensorType2" ], " ambient-temp" ) == 0 ) {
336+ msg_DS18X20Add.sensor_types [1 ] =
337+ wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE;
338+ } else {
339+ WS_DEBUG_PRINTLN (
340+ " [SD] FATAL Parsing error - Unsupported ds18x sensor "
341+ " type found in JSON!" );
342+ return false ;
343+ }
327344 }
328- } else {
329- WS_DEBUG_PRINTLN (" [SD] FATAL Parsing error - Unsupported ds18x sensor "
330- " type count found in JSON!" );
331- return false ;
332345 }
333346
334347 // Configure the signal message for the ds18x20 payload
0 commit comments