ignore n/a values iin mqtt too

This commit is contained in:
Paul
2019-07-06 17:14:02 +02:00
parent e0f07e52e2
commit 61e8f093de
2 changed files with 6 additions and 4 deletions

View File

@@ -178,7 +178,7 @@ char * _bool_to_char(char * s, uint8_t value) {
// negative values are assumed stored as 1-compliment (https://medium.com/@LeeJulija/how-integers-are-stored-in-memory-using-twos-complement-5ba04d61a56c) // negative values are assumed stored as 1-compliment (https://medium.com/@LeeJulija/how-integers-are-stored-in-memory-using-twos-complement-5ba04d61a56c)
char * _short_to_char(char * s, int16_t value, uint8_t decimals = 1) { char * _short_to_char(char * s, int16_t value, uint8_t decimals = 1) {
// remove errors or invalid values // remove errors or invalid values
if ((value == EMS_VALUE_SHORT_NOTSET) || (value == 0x8000)) { if (value == EMS_VALUE_SHORT_NOTSET) {
strlcpy(s, "?", 10); strlcpy(s, "?", 10);
return (s); return (s);
} }
@@ -216,7 +216,7 @@ char * _short_to_char(char * s, int16_t value, uint8_t decimals = 1) {
// decimals: 0 = no division, 1=divide value by 10, 2=divide by 2, 10=divide value by 100 // decimals: 0 = no division, 1=divide value by 10, 2=divide by 2, 10=divide value by 100
char * _ushort_to_char(char * s, uint16_t value, uint8_t decimals = 1) { char * _ushort_to_char(char * s, uint16_t value, uint8_t decimals = 1) {
// remove errors or invalid values // remove errors or invalid values
if ((value == EMS_VALUE_USHORT_NOTSET) || (value == 0x8000)) { if (value == EMS_VALUE_USHORT_NOTSET) {
strlcpy(s, "?", 10); strlcpy(s, "?", 10);
return (s); return (s);
} }
@@ -643,6 +643,8 @@ void publishSensorValues() {
} }
} }
// send values via MQTT // send values via MQTT
// a json object is created for the boiler and one for the thermostat // a json object is created for the boiler and one for the thermostat
// CRC check is done to see if there are changes in the values since the last send to avoid too much wifi traffic // CRC check is done to see if there are changes in the values since the last send to avoid too much wifi traffic

View File

@@ -33,12 +33,12 @@
// max length of a telegram, including CRC, for Rx and Tx. // max length of a telegram, including CRC, for Rx and Tx.
#define EMS_MAX_TELEGRAM_LENGTH 32 #define EMS_MAX_TELEGRAM_LENGTH 32
// default values // default values for null values
#define EMS_VALUE_INT_ON 1 // boolean true #define EMS_VALUE_INT_ON 1 // boolean true
#define EMS_VALUE_INT_OFF 0 // boolean false #define EMS_VALUE_INT_OFF 0 // boolean false
#define EMS_VALUE_INT_NOTSET 0xFF // for 8-bit unsigned ints/bytes #define EMS_VALUE_INT_NOTSET 0xFF // for 8-bit unsigned ints/bytes
#define EMS_VALUE_SHORT_NOTSET -32768 // for 2-byte signed shorts #define EMS_VALUE_SHORT_NOTSET -32768 // for 2-byte signed shorts
#define EMS_VALUE_USHORT_NOTSET 0xFFFF // for 2-byte unsigned shorts #define EMS_VALUE_USHORT_NOTSET 0x8000 // for 2-byte unsigned shorts
#define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs #define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs
#define EMS_THERMOSTAT_WRITE_YES true #define EMS_THERMOSTAT_WRITE_YES true