7static const char *
const TAG =
"remote.aeha";
9static constexpr uint16_t BITWISE = 425;
10static constexpr uint16_t HEADER_HIGH_US = BITWISE * 8;
11static constexpr uint16_t HEADER_LOW_US = BITWISE * 4;
12static constexpr uint16_t BIT_HIGH_US = BITWISE;
13static constexpr uint16_t BIT_ONE_LOW_US = BITWISE * 3;
14static constexpr uint16_t BIT_ZERO_LOW_US = BITWISE;
15static constexpr uint16_t TRAILER = BITWISE;
18 dst->
reserve(2 + 32 + (data.data.size() * 2) + 1);
20 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
22 for (uint16_t mask = 1 << 15; mask != 0; mask >>= 1) {
23 if (data.address & mask) {
24 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
26 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
30 for (uint8_t bit : data.data) {
31 for (uint8_t mask = 1 << 7; mask != 0; mask >>= 1) {
33 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
35 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
47 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
50 for (uint16_t mask = 1 << 15; mask != 0; mask >>= 1) {
53 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
62 for (uint8_t mask = 1 << 7; mask != 0; mask >>= 1) {
65 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
74 out.data.push_back(data);
84std::string AEHAProtocol::format_data_(
const std::vector<uint8_t> &data) {
86 for (uint8_t
byte : data) {
88 snprintf(buf,
sizeof(buf),
"0x%02X,",
byte);
96 auto data_str = format_data_(data.data);
97 ESP_LOGI(TAG,
"Received AEHA: address=0x%04X, data=[%s]", data.address, data_str.c_str());
void dump(const AEHAData &data) override
void encode(RemoteTransmitData *dst, const AEHAData &data) override
optional< AEHAData > decode(RemoteReceiveData src) override
bool expect_item(uint32_t mark, uint32_t space)
bool expect_mark(uint32_t length)
void mark(uint32_t length)
void item(uint32_t mark, uint32_t space)
void reserve(uint32_t len)