5 namespace remote_base {
7 static const char *
const TAG =
"remote.dooya";
9 static const uint32_t HEADER_HIGH_US = 5000;
10 static const uint32_t HEADER_LOW_US = 1500;
11 static const uint32_t BIT_ZERO_HIGH_US = 350;
12 static const uint32_t BIT_ZERO_LOW_US = 750;
13 static const uint32_t BIT_ONE_HIGH_US = 750;
14 static const uint32_t BIT_ONE_LOW_US = 350;
20 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
22 for (uint32_t mask = 1UL << (23); mask != 0; mask >>= 1) {
24 dst->
item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US);
26 dst->
item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US);
30 for (uint32_t mask = 1UL << (7); mask != 0; mask >>= 1) {
32 dst->
item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US);
34 dst->
item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US);
38 for (uint32_t mask = 1UL << (3); mask != 0; mask >>= 1) {
40 dst->
item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US);
42 dst->
item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US);
46 for (uint32_t mask = 1UL << (3); mask != 0; mask >>= 1) {
47 if (data.
check & mask) {
48 dst->
item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US);
50 dst->
item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US);
61 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
64 for (uint8_t i = 0; i < 24; i++) {
65 if (src.
expect_item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US)) {
66 out.id = (out.id << 1) | 1;
67 }
else if (src.
expect_item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US)) {
68 out.id = (out.id << 1) | 0;
74 for (uint8_t i = 0; i < 8; i++) {
75 if (src.
expect_item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US)) {
76 out.channel = (out.channel << 1) | 1;
77 }
else if (src.
expect_item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US)) {
78 out.channel = (out.channel << 1) | 0;
84 for (uint8_t i = 0; i < 4; i++) {
85 if (src.
expect_item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US)) {
86 out.button = (out.button << 1) | 1;
87 }
else if (src.
expect_item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US)) {
88 out.button = (out.button << 1) | 0;
94 for (uint8_t i = 0; i < 3; i++) {
95 if (src.
expect_item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US)) {
96 out.check = (out.check << 1) | 1;
97 }
else if (src.
expect_item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US)) {
98 out.check = (out.check << 1) | 0;
105 out.check = (out.check << 1) | 1;
107 out.check = (out.check << 1) | 0;
115 ESP_LOGI(TAG,
"Received Dooya: id=0x%08" PRIX32
", channel=%d, button=%d, check=%d", data.
id, data.
channel,
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
bool expect_mark(uint32_t length)
void encode(RemoteTransmitData *dst, const DooyaData &data) override
void dump(const DooyaData &data) override
Implementation of SPI Controller mode.
void reserve(uint32_t len)
optional< DooyaData > decode(RemoteReceiveData src) override
bool expect_item(uint32_t mark, uint32_t space)