mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
check length for roomctrl response, dev.2c
This commit is contained in:
@@ -1292,7 +1292,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
|||||||
uint8_t first_value = data[0];
|
uint8_t first_value = data[0];
|
||||||
if (((first_value & 0x7F) == txservice_.ems_bus_id()) && (length > 1)) {
|
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
|
// 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
|
#ifdef EMSESP_UART_DEBUG
|
||||||
// get_uptime is only updated once per loop, does not give the right time
|
// 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());
|
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
|
#ifdef EMSESP_UART_DEBUG
|
||||||
LOG_TRACE("[UART_DEBUG] Reply after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
LOG_TRACE("[UART_DEBUG] Reply after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
||||||
#endif
|
#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
|
rxservice_.add(data, length); // add to RxQueue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,11 +118,11 @@ void Roomctrl::send(const uint8_t addr) {
|
|||||||
/**
|
/**
|
||||||
* check if there is a message for the remote room controller
|
* 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);
|
uint8_t hc = get_hc(addr & 0x7F);
|
||||||
|
|
||||||
// check address, reply only on addresses 0x18..0x1B
|
// check address, reply only on addresses 0x18..0x1B
|
||||||
if (hc >= HCS) {
|
if (hc >= HCS || length < 5) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// no reply if the temperature is not set
|
// 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
|
// empty message back if temperature not set or unknown message type
|
||||||
if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
|
if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
|
||||||
version(addr, data[0]);
|
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]);
|
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) {
|
} else if (data[2] == 0xAF && data[3] == 0) {
|
||||||
temperature(addr, data[0], hc);
|
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);
|
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);
|
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);
|
humidity(addr, data[0], hc);
|
||||||
} else {
|
} else if (length == 5) { // ems query
|
||||||
unknown(addr, data[0], data[2], data[3]);
|
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);
|
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
|
* send the room temperature in message 0xAF
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace emsesp {
|
|||||||
class Roomctrl {
|
class Roomctrl {
|
||||||
public:
|
public:
|
||||||
static void send(const uint8_t addr);
|
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_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);
|
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 };
|
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 uint8_t get_hc(const uint8_t addr);
|
||||||
static void version(uint8_t addr, uint8_t dst);
|
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 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 temperature(uint8_t addr, uint8_t dst, uint8_t hc);
|
||||||
static void humidity(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();
|
static void nack_write();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.6.3-dev.2b"
|
#define EMSESP_APP_VERSION "3.6.3-dev.2c"
|
||||||
|
|||||||
Reference in New Issue
Block a user