diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 94aff0b98..8306777b0 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1292,7 +1292,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { uint8_t first_value = data[0]; if (((first_value & 0x7F) == txservice_.ems_bus_id()) && (length > 1)) { // if we ask ourself at roomcontrol for version e.g. 0B 98 02 00 20 - Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); + Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data, length); #ifdef EMSESP_UART_DEBUG // get_uptime is only updated once per loop, does not give the right time LOG_TRACE("[UART_DEBUG] Echo after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str()); @@ -1392,7 +1392,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { #ifdef EMSESP_UART_DEBUG LOG_TRACE("[UART_DEBUG] Reply after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str()); #endif - Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); // check if there is a message for the roomcontroller + Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data, length); // check if there is a message for the roomcontroller rxservice_.add(data, length); // add to RxQueue } diff --git a/src/roomcontrol.cpp b/src/roomcontrol.cpp index 9ec87cd79..c8b20f5f8 100644 --- a/src/roomcontrol.cpp +++ b/src/roomcontrol.cpp @@ -118,11 +118,11 @@ void Roomctrl::send(const uint8_t addr) { /** * check if there is a message for the remote room controller */ -void Roomctrl::check(const uint8_t addr, const uint8_t * data) { +void Roomctrl::check(const uint8_t addr, const uint8_t * data, const uint8_t length) { uint8_t hc = get_hc(addr & 0x7F); // check address, reply only on addresses 0x18..0x1B - if (hc >= HCS) { + if (hc >= HCS || length < 5) { return; } // no reply if the temperature is not set @@ -138,18 +138,22 @@ void Roomctrl::check(const uint8_t addr, const uint8_t * data) { // empty message back if temperature not set or unknown message type if (data[2] == EMSdevice::EMS_TYPE_VERSION) { version(addr, data[0]); - } else if (remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) { + } else if (length == 5 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) { unknown(addr, data[0], data[2], data[3]); + } else if (length == 7 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) { + unknown(addr, data[0], data[3], data[5], data[6]); } else if (data[2] == 0xAF && data[3] == 0) { temperature(addr, data[0], hc); - } else if (data[2] == 0xFF && data[3] == 0 && data[5] == 0 && data[6] == 0x23) { // Junkers + } else if (length == 7 && data[2] == 0xFF && data[3] == 0 && data[5] == 0 && data[6] == 0x23) { // Junkers temperature(addr, data[0], hc); - } else if (data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x2B) { // EMS+ temperature + } else if (length == 7 && data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x2B) { // EMS+ temperature temperature(addr, data[0], hc); - } else if (data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x7B && remotehum_[hc] != EMS_VALUE_SHORT_NOTSET) { // EMS+ humidity + } else if (length == 7 && data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x7B && remotehum_[hc] != EMS_VALUE_SHORT_NOTSET) { // EMS+ humidity humidity(addr, data[0], hc); - } else { + } else if (length == 5) { // ems query unknown(addr, data[0], data[2], data[3]); + } else if (length == 7 && data[2] == 0xFF) { // ems+ query + unknown(addr, data[0], data[3], data[5], data[6]); } } @@ -182,6 +186,18 @@ void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset) EMSuart::transmit(data, 5); } +void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh, uint8_t typel) { + uint8_t data[10]; + data[0] = addr; + data[1] = dst; + data[2] = 0xFF; + data[3] = offset; + data[4] = typeh; + data[5] = typel; + data[6] = EMSbus::calculate_crc(data, 6); // apppend CRC + EMSuart::transmit(data, 7); +} + /** * send the room temperature in message 0xAF */ diff --git a/src/roomcontrol.h b/src/roomcontrol.h index eff6a8022..836c6441f 100644 --- a/src/roomcontrol.h +++ b/src/roomcontrol.h @@ -25,7 +25,7 @@ namespace emsesp { class Roomctrl { public: static void send(const uint8_t addr); - static void check(const uint8_t addr, const uint8_t * data); + static void check(const uint8_t addr, const uint8_t * data, const uint8_t length); static void set_remotetemp(const uint8_t type, const uint8_t hc, const int16_t temp); static void set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum); enum : uint8_t { RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40 }; @@ -38,6 +38,7 @@ class Roomctrl { static uint8_t get_hc(const uint8_t addr); static void version(uint8_t addr, uint8_t dst); static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset); + static void unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh, uint8_t typel); static void temperature(uint8_t addr, uint8_t dst, uint8_t hc); static void humidity(uint8_t addr, uint8_t dst, uint8_t hc); static void nack_write(); diff --git a/src/version.h b/src/version.h index 3815c3f9e..bcb83a738 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.3-dev.2b" +#define EMSESP_APP_VERSION "3.6.3-dev.2c"