clang style formatting

This commit is contained in:
proddy
2020-06-04 22:22:36 +02:00
parent 373597e7e6
commit e7f2d194ae
3 changed files with 32 additions and 29 deletions

View File

@@ -564,9 +564,11 @@ 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 ... // if we ask ourself at roomcontrol for version e.g. 0B 98 02 ...
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data, length); Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data);
rxservice_.add(data, length); // just for logging #ifdef EMSESP_DEBUG
return; // it's an echo rxservice_.add(data, length); // just for logging, if compiled with additional debugging
#endif
return; // it's an echo
} }
// are we waiting for a response from a recent Tx Read or Write? // are we waiting for a response from a recent Tx Read or Write?
@@ -627,7 +629,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
return; return;
} else { } else {
// check if there is a message for the roomcontroller // check if there is a message for the roomcontroller
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data, length); Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data);
// add to RxQueue, what ever it is. // add to RxQueue, what ever it is.
rxservice_.add(data, length); rxservice_.add(data, length);
} }

View File

@@ -18,19 +18,16 @@
#include "roomcontrol.h" #include "roomcontrol.h"
MAKE_PSTR(logger_name, "roomctrl")
namespace emsesp { namespace emsesp {
uint32_t rc_time_ = 0; uint32_t rc_time_ = 0;
uint16_t hc_ = EMS_VALUE_USHORT_NOTSET; uint16_t hc_ = EMS_VALUE_USHORT_NOTSET;
int16_t remotetemp[4] = { int16_t remotetemp[4] = {EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET};
EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET
};
/** /**
* set the temperature, * set the temperature,
*/ */
void Roomctrl::set_remotetemp(uint8_t hc, int16_t temp){ void Roomctrl::set_remotetemp(uint8_t hc, int16_t temp) {
remotetemp[hc] = temp; remotetemp[hc] = temp;
} }
@@ -47,9 +44,9 @@ void Roomctrl::send(uint8_t addr) {
if (remotetemp[hc_] == EMS_VALUE_SHORT_NOTSET) { if (remotetemp[hc_] == EMS_VALUE_SHORT_NOTSET) {
return; return;
} }
if (millis() - rc_time_ > 60000) { // send every minute if (uuid::get_uptime() - rc_time_ > SEND_INTERVAL) { // send every minute
rc_time_ = millis(); rc_time_ = uuid::get_uptime(); // use EMS-ESP's millis() to prevent overhead
temperature(addr, 0x00); // send to all temperature(addr, 0x00); // send to all
} else { } else {
// acknowledge every poll, otherwise the master shows error A11-822 // acknowledge every poll, otherwise the master shows error A11-822
EMSuart::send_poll(addr); EMSuart::send_poll(addr);
@@ -59,16 +56,19 @@ void Roomctrl::send(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(uint8_t addr, uint8_t * data, const uint8_t length) { void Roomctrl::check(uint8_t addr, uint8_t * data) {
uint8_t hc_num = addr - ADDR; uint8_t hc_num = addr - ADDR;
// check address, reply only on addresses 0x18..0x1B // check address, reply only on addresses 0x18..0x1B
if (hc_num > 3) { if (hc_num > 3) {
return; return;
} }
// no reply if the temperature is not set // no reply if the temperature is not set
if (remotetemp[hc_num] == EMS_VALUE_SHORT_NOTSET) { if (remotetemp[hc_num] == EMS_VALUE_SHORT_NOTSET) {
return; return;
} }
// for now we only reply to version and remote temperature // for now we only reply to version and remote temperature
if (data[2] == 0x02) { if (data[2] == 0x02) {
version(addr, data[0]); version(addr, data[0]);
@@ -114,14 +114,14 @@ void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset)
void Roomctrl::temperature(uint8_t addr, uint8_t dst) { void Roomctrl::temperature(uint8_t addr, uint8_t dst) {
uint8_t data[10]; uint8_t data[10];
uint8_t hc_ = addr - ADDR; uint8_t hc_ = addr - ADDR;
data[0] = addr; data[0] = addr;
data[1] = dst; data[1] = dst;
data[2] = 0xAF; data[2] = 0xAF;
data[3] = 0; data[3] = 0;
data[4] = (uint8_t)(remotetemp[hc_] >> 8); data[4] = (uint8_t)(remotetemp[hc_] >> 8);
data[5] = (uint8_t)(remotetemp[hc_] & 0xFF); data[5] = (uint8_t)(remotetemp[hc_] & 0xFF);
data[6] = 0; data[6] = 0;
data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC
EMSuart::transmit(data, 8); EMSuart::transmit(data, 8);
} }

View File

@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef EMSESP_ROOMCTRL_H #ifndef EMSESP_ROOMCONTROL_H
#define EMSESP_ROOMCTRL_H #define EMSESP_ROOMCONTROL_H
#include "emsesp.h" #include "emsesp.h"
#include "telegram.h" #include "telegram.h"
@@ -29,15 +29,16 @@ namespace emsesp {
class Roomctrl { class Roomctrl {
public: public:
static void send(uint8_t addr); static void send(uint8_t addr);
static void check(uint8_t addr, uint8_t * data, const uint8_t length); static void check(uint8_t addr, uint8_t * data);
static void set_remotetemp(uint8_t hc, int16_t temp); static void set_remotetemp(uint8_t hc, int16_t temp);
private: private:
#define ADDR 0x18 static constexpr uint8_t ADDR = 0x18;
static constexpr uint32_t SEND_INTERVAL = 60000; // 1 minute
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 temperature(uint8_t addr, uint8_t dst); static void temperature(uint8_t addr, uint8_t dst);
}; };
} // namespace emsesp } // namespace emsesp