16static const uint8_t TX_NIBBLE[] = {0xF6, 0xEE, 0xED, 0xEB, 0xDE, 0xDD, 0xDB, 0xBE,
17 0xBD, 0xBB, 0xB7, 0x7E, 0x7D, 0x7B, 0x77, 0x6F};
19static const uint8_t TX_STATE_IDLE = 0;
20static const uint8_t TX_STATE_MSGSTART = 1;
21static const uint8_t TX_STATE_BYTESTART = 2;
22static const uint8_t TX_STATE_SENDBYTE = 3;
23static const uint8_t TX_STATE_MSGEND = 4;
24static const uint8_t TX_STATE_GAPSTART = 5;
25static const uint8_t TX_STATE_GAPEND = 6;
31static void IRAM_ATTR isr_t_xtimer(
LwTx *arg) {
46 case TX_STATE_MSGSTART:
51 case TX_STATE_BYTESTART:
56 case TX_STATE_SENDBYTE:
78 case TX_STATE_GAPSTART:
111 ESP_LOGW(
"lightwaverf.sensor",
"Message too short: %zu < %u", msg.size(),
static_cast<unsigned>(
TX_MSGLEN));
115 for (uint8_t i = 0; i <
TX_MSGLEN; i++) {
116 this->
tx_buf[i] = TX_NIBBLE[msg[i] & 0xF];
117 ESP_LOGD(
"lightwaverf.sensor",
"%x ", msg[i]);
130 for (uint8_t i = 0; i < 5; i++) {
131 this->
tx_buf[i + 4] = TX_NIBBLE[addr[i] & 0xF];
138void LwTx::lwtx_cmd(uint8_t command, uint8_t parameter, uint8_t room, uint8_t device) {
140 this->
tx_buf[0] = TX_NIBBLE[parameter >> 4];
141 this->
tx_buf[1] = TX_NIBBLE[parameter & 0xF];
142 this->
tx_buf[2] = TX_NIBBLE[device & 0xF];
143 this->
tx_buf[3] = TX_NIBBLE[command & 0xF];
144 this->
tx_buf[9] = TX_NIBBLE[room & 0xF];
159 if (repeats > 0 && repeats < 40) {
196 timer1_attachInterrupt([] { isr_t_xtimer(arg); });
197 timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP);
206 timer1_detachInterrupt();
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
Helper class to disable interrupts.
void lwtx_set_gap_multiplier(uint8_t gap_multiplier)
uint8_t tx_buf[TX_MSGLEN]
void lwtx_setup(InternalGPIOPin *pin, uint8_t repeats, bool inverted, int u_sec)
Set things up to transmit LightWaveRF 434Mhz messages.
void lwtx_set_tick_counts(uint8_t low_count, uint8_t high_count, uint8_t trail_count, uint8_t gap_count)
static const uint8_t TX_MSGLEN
volatile bool tx_msg_active
void lwtx_send(const std::vector< uint8_t > &msg)
Send a LightwaveRF message (10 nibbles in bytes)
void lwtx_settranslate(bool txtranslate)
Set translate mode.
void lwtx_cmd(uint8_t command, uint8_t parameter, uint8_t room, uint8_t device)
Send a LightwaveRF message (10 nibbles in bytes)
uint8_t tx_gap_multiplier
void lwtx_setaddr(const uint8_t *addr)
Set 5 char address for future messages.
bool lwtx_free()
Check for send free.