mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
thermostat emulation check ht3 adddress
This commit is contained in:
@@ -1310,7 +1310,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) == EMSbus::ems_bus_id()) && (length > 1)) {
|
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
|
// 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
|
#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());
|
||||||
@@ -1410,7 +1410,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, 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
|
rxservice_.add(data, length); // add to RxQueue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
uint8_t Roomctrl::get_hc(uint8_t addr) {
|
||||||
|
addr &= 0x7F;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case SENSOR:
|
case SENSOR:
|
||||||
return addr - 0x40;
|
return addr - 0x40;
|
||||||
@@ -121,15 +122,15 @@ void Roomctrl::send(const uint8_t addr) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// acknowledge every poll, otherwise the master shows error A22-816
|
// 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
|
* 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) {
|
void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
|
||||||
uint8_t hc = get_hc(addr & 0x7F);
|
uint8_t hc = get_hc(addr);
|
||||||
|
|
||||||
// check address, reply only on addresses 0x18..0x1B
|
// check address, reply only on addresses 0x18..0x1B
|
||||||
if (hc >= HCS || length < 5) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// reply to writes with write nack byte
|
// reply to writes with write nack byte
|
||||||
if (addr & 0x80) { // it's a write to us
|
if ((addr & 0x80) == 0) { // it's a write to us
|
||||||
nack_write(); // we don't accept writes.
|
nack_write(); // we don't accept writes.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
addr &= 0x7F;
|
||||||
// reads: for now we only reply to version and remote temperature
|
// reads: for now we only reply to version and remote temperature
|
||||||
// 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) {
|
||||||
@@ -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) {
|
void Roomctrl::version(uint8_t addr, uint8_t dst) {
|
||||||
uint8_t data[15];
|
uint8_t data[15];
|
||||||
data[0] = addr;
|
data[0] = addr ^ EMSbus::ems_mask();
|
||||||
data[1] = dst;
|
data[1] = dst;
|
||||||
data[2] = 0x02;
|
data[2] = 0x02;
|
||||||
data[3] = 0;
|
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) {
|
void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset) {
|
||||||
uint8_t data[10];
|
uint8_t data[10];
|
||||||
data[0] = addr;
|
data[0] = addr ^ EMSbus::ems_mask();
|
||||||
data[1] = dst;
|
data[1] = dst;
|
||||||
data[2] = type;
|
data[2] = type;
|
||||||
data[3] = offset;
|
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) {
|
void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh, uint8_t typel) {
|
||||||
uint8_t data[10];
|
uint8_t data[10];
|
||||||
data[0] = addr;
|
data[0] = addr ^ EMSbus::ems_mask();
|
||||||
data[1] = dst;
|
data[1] = dst;
|
||||||
data[2] = 0xFF;
|
data[2] = 0xFF;
|
||||||
data[3] = offset;
|
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) {
|
void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
|
||||||
uint8_t data[12];
|
uint8_t data[12];
|
||||||
data[0] = addr;
|
data[0] = addr ^ EMSbus::ems_mask();
|
||||||
data[1] = dst;
|
data[1] = dst;
|
||||||
if (type_ == RC20) { // RC20, telegram 0xAF
|
if (type_ == RC20) { // RC20, telegram 0xAF
|
||||||
data[2] = 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
|
// send telegram 0x047B only for RC100H
|
||||||
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
|
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
|
||||||
uint8_t data[11];
|
uint8_t data[11];
|
||||||
data[0] = addr;
|
data[0] = addr ^ EMSbus::ems_mask();
|
||||||
data[1] = dst;
|
data[1] = dst;
|
||||||
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
|
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
|
||||||
if (type_ == RC100H) { // RC100H, telegram 47B
|
if (type_ == RC100H) { // RC100H, telegram 47B
|
||||||
|
|||||||
@@ -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, 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_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, RC200 = 157 };
|
enum : uint8_t { RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40, RC200 = 157 };
|
||||||
|
|||||||
Reference in New Issue
Block a user