thermostat emulation check ht3 adddress

This commit is contained in:
MichaelDvP
2024-02-05 07:28:36 +01:00
parent 51b0a0ae5b
commit 6564e444ab
3 changed files with 15 additions and 13 deletions

View File

@@ -1310,7 +1310,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
uint8_t first_value = data[0];
if (((first_value & 0x7F) == EMSbus::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, length);
Roomctrl::check(data[1], 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());
@@ -1410,7 +1410,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, length); // check if there is a message for the roomcontroller
Roomctrl::check(data[1], data, length); // check if there is a message for the roomcontroller
rxservice_.add(data, length); // add to RxQueue
}

View File

@@ -62,6 +62,7 @@ void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t
}
uint8_t Roomctrl::get_hc(uint8_t addr) {
addr &= 0x7F;
switch (type_) {
case SENSOR:
return addr - 0x40;
@@ -121,15 +122,15 @@ void Roomctrl::send(const uint8_t addr) {
}
} else {
// acknowledge every poll, otherwise the master shows error A22-816
EMSuart::send_poll(addr);
EMSuart::send_poll(addr ^ EMSbus::ems_mask());
}
}
/**
* check if there is a message for the remote room controller
*/
void Roomctrl::check(const uint8_t addr, const uint8_t * data, const uint8_t length) {
uint8_t hc = get_hc(addr & 0x7F);
void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
uint8_t hc = get_hc(addr);
// check address, reply only on addresses 0x18..0x1B
if (hc >= HCS || length < 5) {
@@ -140,10 +141,11 @@ void Roomctrl::check(const uint8_t addr, const uint8_t * data, const uint8_t len
return;
}
// reply to writes with write nack byte
if (addr & 0x80) { // it's a write to us
nack_write(); // we don't accept writes.
if ((addr & 0x80) == 0) { // it's a write to us
nack_write(); // we don't accept writes.
return;
}
addr &= 0x7F;
// reads: for now we only reply to version and remote temperature
// empty message back if temperature not set or unknown message type
if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
@@ -172,7 +174,7 @@ void Roomctrl::check(const uint8_t addr, const uint8_t * data, const uint8_t len
*/
void Roomctrl::version(uint8_t addr, uint8_t dst) {
uint8_t data[15];
data[0] = addr;
data[0] = addr ^ EMSbus::ems_mask();
data[1] = dst;
data[2] = 0x02;
data[3] = 0;
@@ -199,7 +201,7 @@ void Roomctrl::version(uint8_t addr, uint8_t dst) {
*/
void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset) {
uint8_t data[10];
data[0] = addr;
data[0] = addr ^ EMSbus::ems_mask();
data[1] = dst;
data[2] = type;
data[3] = offset;
@@ -209,7 +211,7 @@ void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset)
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[0] = addr ^ EMSbus::ems_mask();
data[1] = dst;
data[2] = 0xFF;
data[3] = offset;
@@ -224,7 +226,7 @@ void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh,
*/
void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[12];
data[0] = addr;
data[0] = addr ^ EMSbus::ems_mask();
data[1] = dst;
if (type_ == RC20) { // RC20, telegram 0xAF
data[2] = 0xAF;
@@ -280,7 +282,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
// send telegram 0x047B only for RC100H
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[11];
data[0] = addr;
data[0] = addr ^ EMSbus::ems_mask();
data[1] = dst;
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
if (type_ == RC100H) { // RC100H, telegram 47B

View File

@@ -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, const uint8_t length);
static void check(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, RC200 = 157 };