ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
sx126x.cpp
Go to the documentation of this file.
1#include "sx126x.h"
3#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5
6namespace esphome::sx126x {
7
8ESPHOME_LOG_TAG(TAG, "sx126x");
9static const uint16_t RAMP[8] = {10, 20, 40, 80, 200, 800, 1700, 3400};
10static const uint32_t BW_HZ[31] = {4800, 5800, 7300, 9700, 11700, 14600, 19500, 23400, 29300, 39000, 46900,
11 58600, 78200, 93800, 117300, 156200, 187200, 234300, 312000, 373600, 467000, 7810,
12 10420, 15630, 20830, 31250, 41670, 62500, 125000, 250000, 500000};
13static const uint8_t BW_LORA[10] = {LORA_BW_7810, LORA_BW_10420, LORA_BW_15630, LORA_BW_20830, LORA_BW_31250,
15static const uint8_t BW_FSK[21] = {
19
20static constexpr uint32_t RESET_DELAY_HIGH_US = 5000;
21static constexpr uint32_t RESET_DELAY_LOW_US = 2000;
22static constexpr uint32_t SWITCHING_DELAY_US = 1;
23static constexpr uint32_t TRANSMIT_TIMEOUT_MS = 4000;
24static constexpr uint32_t BUSY_TIMEOUT_MS = 20;
25
26// OCP (Over Current Protection) values
27static constexpr uint8_t OCP_80MA = 0x18; // 80 mA max current
28static constexpr uint8_t OCP_140MA = 0x38; // 140 mA max current
29
30// LoRa low data rate optimization threshold
31static constexpr float LOW_DATA_RATE_OPTIMIZE_THRESHOLD = 16.38f; // 16.38 ms
32
33uint8_t SX126x::read_fifo_(uint8_t offset, std::vector<uint8_t> &packet) {
34 this->enable();
35 this->wait_busy_();
37 this->transfer_byte(offset);
38 uint8_t status = this->transfer_byte(0x00);
39 for (uint8_t &byte : packet) {
40 byte = this->transfer_byte(0x00);
41 }
42 this->disable();
43 return status;
44}
45
46void SX126x::write_fifo_(uint8_t offset, const uint8_t *data, size_t len) {
47 this->enable();
48 this->wait_busy_();
50 this->transfer_byte(offset);
51 for (size_t i = 0; i < len; i++) {
52 this->transfer_byte(data[i]);
53 }
54 this->disable();
55 delayMicroseconds(SWITCHING_DELAY_US);
56}
57
58uint8_t SX126x::read_opcode_(uint8_t opcode, uint8_t *data, uint8_t size) {
59 this->enable();
60 this->wait_busy_();
61 this->transfer_byte(opcode);
62 uint8_t status = this->transfer_byte(0x00);
63 for (int32_t i = 0; i < size; i++) {
64 data[i] = this->transfer_byte(0x00);
65 }
66 this->disable();
67 return status;
68}
69
70void SX126x::write_opcode_(uint8_t opcode, uint8_t *data, uint8_t size) {
71 this->enable();
72 this->wait_busy_();
73 this->transfer_byte(opcode);
74 for (int32_t i = 0; i < size; i++) {
75 this->transfer_byte(data[i]);
76 }
77 this->disable();
78 delayMicroseconds(SWITCHING_DELAY_US);
79}
80
81void SX126x::read_register_(uint16_t reg, uint8_t *data, uint8_t size) {
82 this->enable();
83 this->wait_busy_();
85 this->write_byte((reg >> 8) & 0xFF);
86 this->write_byte((reg >> 0) & 0xFF);
87 this->write_byte(0x00);
88 for (int32_t i = 0; i < size; i++) {
89 data[i] = this->transfer_byte(0x00);
90 }
91 this->disable();
92}
93
94void SX126x::write_register_(uint16_t reg, uint8_t *data, uint8_t size) {
95 this->enable();
96 this->wait_busy_();
98 this->write_byte((reg >> 8) & 0xFF);
99 this->write_byte((reg >> 0) & 0xFF);
100 for (int32_t i = 0; i < size; i++) {
101 this->transfer_byte(data[i]);
102 }
103 this->disable();
104 delayMicroseconds(SWITCHING_DELAY_US);
105}
106
108
110 // setup pins
111 this->busy_pin_->setup();
112 this->rst_pin_->setup();
113 this->dio1_pin_->setup();
114 if (this->dio1_pin_->is_internal()) {
115 static_cast<InternalGPIOPin *>(this->dio1_pin_)
116 ->attach_interrupt(&SX126x::gpio_intr, this, gpio::INTERRUPT_RISING_EDGE);
117 }
118
119 // start spi
120 this->spi_setup();
121
122 // configure rf
123 this->configure();
124}
125
127 uint8_t buf[8];
128
129 // toggle chip reset
130 this->rst_pin_->digital_write(true);
131 delayMicroseconds(RESET_DELAY_HIGH_US);
132 this->rst_pin_->digital_write(false);
133 delayMicroseconds(RESET_DELAY_LOW_US);
134 this->rst_pin_->digital_write(true);
135 delayMicroseconds(RESET_DELAY_HIGH_US);
136
137 // wakeup
138 this->read_opcode_(RADIO_GET_STATUS, nullptr, 0);
139
140 // config tcxo
141 if (this->tcxo_voltage_ != TCXO_CTRL_NONE) {
142 uint32_t delay = this->tcxo_delay_ >> 6;
143 buf[0] = this->tcxo_voltage_;
144 buf[1] = (delay >> 16) & 0xFF;
145 buf[2] = (delay >> 8) & 0xFF;
146 buf[3] = (delay >> 0) & 0xFF;
147 this->write_opcode_(RADIO_SET_TCXOMODE, buf, 4);
148 buf[0] = 0x7F;
149 this->write_opcode_(RADIO_CALIBRATE, buf, 1);
150 }
151
152 // clear errors
153 buf[0] = 0x00;
154 buf[1] = 0x00;
155 this->write_opcode_(RADIO_CLR_ERROR, buf, 2);
156
157 // rf switch
158 if (this->rf_switch_) {
159 buf[0] = 0x01;
161 }
162
163 // check silicon version to make sure hw is ok
164 this->read_register_(REG_VERSION_STRING, (uint8_t *) this->version_, sizeof(this->version_));
165 this->version_[sizeof(this->version_) - 1] = '\0';
166 if (strncmp(this->version_, "SX126", 5) != 0 && strncmp(this->version_, "LLCC68", 6) != 0) {
167 this->mark_failed(LOG_STR("Unsupported chip version"));
168 return;
169 }
170
171 // setup packet type
172 buf[0] = this->modulation_;
173 this->write_opcode_(RADIO_SET_PACKETTYPE, buf, 1);
174
175 // calibrate image
176 this->run_image_cal();
177
178 // set frequency
179 uint64_t freq = ((uint64_t) this->frequency_ << 25) / XTAL_FREQ;
180 buf[0] = (uint8_t) ((freq >> 24) & 0xFF);
181 buf[1] = (uint8_t) ((freq >> 16) & 0xFF);
182 buf[2] = (uint8_t) ((freq >> 8) & 0xFF);
183 buf[3] = (uint8_t) (freq & 0xFF);
185
186 // configure pa
187 int8_t pa_power = this->pa_power_;
188 if (this->sx1261_) {
189 // the following values were taken from section 13.1.14.1 table 13-21
190 // in rev 2.1 of the datasheet
191 if (pa_power == 15) {
192 uint8_t cfg[4] = {0x06, 0x00, 0x01, 0x01};
193 this->write_opcode_(RADIO_SET_PACONFIG, cfg, 4);
194 } else {
195 uint8_t cfg[4] = {0x04, 0x00, 0x01, 0x01};
196 this->write_opcode_(RADIO_SET_PACONFIG, cfg, 4);
197 }
198 pa_power = std::max(pa_power, (int8_t) -3);
199 pa_power = std::min(pa_power, (int8_t) 14);
200 buf[0] = OCP_80MA;
201 this->write_register_(REG_OCP, buf, 1);
202 } else {
203 // the following values were taken from section 13.1.14.1 table 13-21
204 // in rev 2.1 of the datasheet
205 uint8_t cfg[4] = {0x04, 0x07, 0x00, 0x01};
206 this->write_opcode_(RADIO_SET_PACONFIG, cfg, 4);
207 pa_power = std::max(pa_power, (int8_t) -3);
208 pa_power = std::min(pa_power, (int8_t) 22);
209 buf[0] = OCP_140MA;
210 this->write_register_(REG_OCP, buf, 1);
211 }
212 buf[0] = pa_power;
213 buf[1] = this->pa_ramp_;
214 this->write_opcode_(RADIO_SET_TXPARAMS, buf, 2);
215
216 // configure modem
217 if (this->modulation_ == PACKET_TYPE_LORA) {
218 // set modulation params
219 float duration = 1000.0f * (1UL << this->spreading_factor_) / BW_HZ[this->bandwidth_];
220 buf[0] = this->spreading_factor_;
221 buf[1] = BW_LORA[this->bandwidth_ - SX126X_BW_7810];
222 buf[2] = this->coding_rate_;
223 buf[3] = (duration > LOW_DATA_RATE_OPTIMIZE_THRESHOLD) ? 0x01 : 0x00;
225
226 // set packet params and sync word
228 if (this->sync_value_.size() == 2) {
229 this->write_register_(REG_LORA_SYNCWORD, this->sync_value_.data(), this->sync_value_.size());
230 }
231 } else {
232 // set modulation params
233 uint32_t bitrate = ((uint64_t) XTAL_FREQ * 32) / this->bitrate_;
234 uint32_t fdev = ((uint64_t) this->deviation_ << 25) / XTAL_FREQ;
235 buf[0] = (bitrate >> 16) & 0xFF;
236 buf[1] = (bitrate >> 8) & 0xFF;
237 buf[2] = (bitrate >> 0) & 0xFF;
238 buf[3] = this->shaping_;
239 buf[4] = BW_FSK[this->bandwidth_ - SX126X_BW_4800];
240 buf[5] = (fdev >> 16) & 0xFF;
241 buf[6] = (fdev >> 8) & 0xFF;
242 buf[7] = (fdev >> 0) & 0xFF;
244
245 // set crc params
246 if (this->crc_enable_) {
247 buf[0] = this->crc_initial_ >> 8;
248 buf[1] = this->crc_initial_ & 0xFF;
249 this->write_register_(REG_CRC_INITIAL, buf, 2);
250 buf[0] = this->crc_polynomial_ >> 8;
251 buf[1] = this->crc_polynomial_ & 0xFF;
252 this->write_register_(REG_CRC_POLYNOMIAL, buf, 2);
253 }
254
255 // set whitening params
256 if (this->whitening_enable_) {
257 // according to the datasheet, section 12 table 12-1 "The user should not
258 // change the value of the 7 MSB of this register"
260 buf[0] = (buf[0] & 0xFE) | ((this->whitening_initial_ >> 8) & 0x01);
261 buf[1] = this->whitening_initial_ & 0xFF;
263 }
264
265 // set packet params and sync word
267 if (!this->sync_value_.empty()) {
268 this->write_register_(REG_GFSK_SYNCWORD, this->sync_value_.data(), this->sync_value_.size());
269 }
270 }
271
272 // switch to rx or sleep
273 if (this->rx_start_) {
274 this->set_mode_rx();
275 } else {
276 this->set_mode_sleep();
277 }
278}
279
281 if (this->payload_length_ > 0) {
282 return this->payload_length_;
283 }
284 return SX126X_MAX_PACKET_SIZE;
285}
286
287void SX126x::set_packet_params_(uint8_t payload_length) {
288 uint8_t buf[9];
289 if (this->modulation_ == PACKET_TYPE_LORA) {
290 buf[0] = (this->preamble_size_ >> 8) & 0xFF;
291 buf[1] = (this->preamble_size_ >> 0) & 0xFF;
292 buf[2] = (this->payload_length_ > 0) ? 0x01 : 0x00;
293 buf[3] = payload_length;
294 buf[4] = (this->crc_enable_) ? 0x01 : 0x00;
295 buf[5] = 0x00;
297 } else {
298 uint16_t preamble_size = this->preamble_size_ * 8;
299 buf[0] = (preamble_size >> 8) & 0xFF;
300 buf[1] = (preamble_size >> 0) & 0xFF;
301 buf[2] = (this->preamble_detect_ > 0) ? ((this->preamble_detect_ - 1) | 0x04) : 0x00;
302 buf[3] = this->sync_value_.size() * 8;
303 buf[4] = 0x00;
304 buf[5] = (this->payload_length_ > 0) ? 0x00 : 0x01;
305 buf[6] = payload_length;
306 if (this->crc_enable_) {
307 buf[7] = (this->crc_inverted_ ? 0x04 : 0x00) + (this->crc_size_ & 0x02);
308 } else {
309 buf[7] = 0x01;
310 }
311 buf[8] = (this->whitening_enable_) ? 0x01 : 0x00;
313 }
314}
315
316SX126xError SX126x::transmit_packet(const uint8_t *data, size_t len) {
317 // Callers such as a template number's on_value can run before setup() or after a failed setup
318 if (!this->is_ready()) {
319 ESP_LOGW(TAG, "Radio not ready, packet dropped");
321 }
322 if (this->payload_length_ > 0 && this->payload_length_ != len) {
323 ESP_LOGE(TAG, "Packet size does not match config");
325 }
326 if (len == 0 || len > this->get_max_packet_size()) {
327 ESP_LOGE(TAG, "Packet size out of range");
329 }
330
333 if (this->payload_length_ == 0) {
334 this->set_packet_params_(len);
335 }
336 this->write_fifo_(0x00, data, len);
337 this->set_mode_tx();
338
339 // wait until transmit completes, typically the delay will be less than 100 ms
340 uint32_t start = millis();
341 while (!this->dio1_pin_->digital_read()) {
342 App.feed_wdt();
343 if (millis() - start > TRANSMIT_TIMEOUT_MS) {
344 ESP_LOGE(TAG, "Transmit packet failure");
346 break;
347 }
348 }
349
350 uint8_t buf[2];
351 buf[0] = 0xFF;
352 buf[1] = 0xFF;
353 this->write_opcode_(RADIO_CLR_IRQSTATUS, buf, 2);
354 if (this->payload_length_ == 0) {
356 }
357 if (this->rx_start_) {
358 this->set_mode_rx();
359 } else {
360 this->set_mode_sleep();
361 }
362 return ret;
363}
364
365void SX126x::call_listeners_(const std::vector<uint8_t> &packet, float rssi, float snr) {
366 for (auto &listener : this->listeners_) {
367 listener->on_packet(packet, rssi, snr);
368 }
369 this->packet_trigger_.trigger(packet, rssi, snr);
370}
371
373 if (this->dio1_pin_->is_internal()) {
374 this->disable_loop();
375 }
376 if (!this->dio1_pin_->digital_read()) {
377 return;
378 }
379
380 uint16_t status;
381 uint8_t buf[3];
382 uint8_t rssi;
383 int8_t snr;
384 this->read_opcode_(RADIO_GET_IRQSTATUS, buf, 2);
385 this->write_opcode_(RADIO_CLR_IRQSTATUS, buf, 2);
386 status = (buf[0] << 8) | buf[1];
387 if ((status & IRQ_RX_DONE) == IRQ_RX_DONE) {
390 if (this->modulation_ == PACKET_TYPE_LORA) {
391 rssi = buf[0];
392 snr = buf[1];
393 } else {
394 rssi = buf[2];
395 snr = 0;
396 }
398 this->packet_.resize(buf[0]);
399 this->read_fifo_(buf[1], this->packet_);
400 this->call_listeners_(this->packet_, (float) rssi / -2.0f, (float) snr / 4.0f);
401 }
402 }
403}
404
406 // the following values were taken from section 9.2.1 table 9-2
407 // in rev 2.1 of the datasheet
408 uint8_t buf[2] = {0, 0};
409 if (this->frequency_ > 900000000) {
410 buf[0] = 0xE1;
411 buf[1] = 0xE9;
412 } else if (this->frequency_ > 850000000) {
413 buf[0] = 0xD7;
414 buf[1] = 0xDB;
415 } else if (this->frequency_ > 770000000) {
416 buf[0] = 0xC1;
417 buf[1] = 0xC5;
418 } else if (this->frequency_ > 460000000) {
419 buf[0] = 0x75;
420 buf[1] = 0x81;
421 } else if (this->frequency_ > 425000000) {
422 buf[0] = 0x6B;
423 buf[1] = 0x6F;
424 }
425 if (buf[0] > 0 && buf[1] > 0) {
426 this->write_opcode_(RADIO_CALIBRATEIMAGE, buf, 2);
427 }
428}
429
431 uint8_t buf[8];
432
433 // configure irq params
435 buf[0] = (irq >> 8) & 0xFF;
436 buf[1] = (irq >> 0) & 0xFF;
437 buf[2] = (irq >> 8) & 0xFF;
438 buf[3] = (irq >> 0) & 0xFF;
439 buf[4] = (IRQ_RADIO_NONE >> 8) & 0xFF;
440 buf[5] = (IRQ_RADIO_NONE >> 0) & 0xFF;
441 buf[6] = (IRQ_RADIO_NONE >> 8) & 0xFF;
442 buf[7] = (IRQ_RADIO_NONE >> 0) & 0xFF;
444
445 // set timeout to 0
446 buf[0] = 0x00;
448
449 // switch to continuous mode rx
450 buf[0] = 0xFF;
451 buf[1] = 0xFF;
452 buf[2] = 0xFF;
453 this->write_opcode_(RADIO_SET_RX, buf, 3);
454}
455
457 uint8_t buf[8];
458
459 // configure irq params
460 uint16_t irq = IRQ_TX_DONE | IRQ_RX_TX_TIMEOUT;
461 buf[0] = (irq >> 8) & 0xFF;
462 buf[1] = (irq >> 0) & 0xFF;
463 buf[2] = (irq >> 8) & 0xFF;
464 buf[3] = (irq >> 0) & 0xFF;
465 buf[4] = (IRQ_RADIO_NONE >> 8) & 0xFF;
466 buf[5] = (IRQ_RADIO_NONE >> 0) & 0xFF;
467 buf[6] = (IRQ_RADIO_NONE >> 8) & 0xFF;
468 buf[7] = (IRQ_RADIO_NONE >> 0) & 0xFF;
470
471 // switch to single mode tx
472 buf[0] = 0x00;
473 buf[1] = 0x00;
474 buf[2] = 0x00;
475 this->write_opcode_(RADIO_SET_TX, buf, 3);
476}
477
478void SX126x::set_mode_sleep(bool cold) {
479 // 0x04 = warm start (config retained), 0x00 = cold start (config lost, lowest power)
480 uint8_t buf[1];
481 buf[0] = cold ? 0x00 : 0x04;
482 this->write_opcode_(RADIO_SET_SLEEP, buf, 1);
483}
484
486 uint8_t buf[1];
487 buf[0] = mode;
488 this->write_opcode_(RADIO_SET_STANDBY, buf, 1);
489}
490
492 // wait if the device is busy, the maximum delay is only be a few ms
493 // with most commands taking only a few us
494 uint32_t start = millis();
495 while (this->busy_pin_->digital_read()) {
496 if (millis() - start > BUSY_TIMEOUT_MS) {
497 this->mark_failed(LOG_STR("Wait busy timeout"));
498 break;
499 }
500 }
501}
502
504 ESP_LOGCONFIG(TAG, "SX126x:");
505 LOG_PIN(" CS Pin: ", this->cs_);
506 LOG_PIN(" BUSY Pin: ", this->busy_pin_);
507 LOG_PIN(" RST Pin: ", this->rst_pin_);
508 LOG_PIN(" DIO1 Pin: ", this->dio1_pin_);
509 ESP_LOGCONFIG(TAG,
510 " HW Version: %15s\n"
511 " Frequency: %" PRIu32 " Hz\n"
512 " Bandwidth: %" PRIu32 " Hz\n"
513 " PA Power: %" PRId8 " dBm\n"
514 " PA Ramp: %" PRIu16 " us\n"
515 " Payload Length: %" PRIu32 "\n"
516 " CRC Enable: %s\n"
517 " Rx Start: %s",
518 this->version_, this->frequency_, BW_HZ[this->bandwidth_], this->pa_power_, RAMP[this->pa_ramp_],
519 this->payload_length_, TRUEFALSE(this->crc_enable_), TRUEFALSE(this->rx_start_));
520 if (this->modulation_ == PACKET_TYPE_GFSK) {
521 const char *shaping = "NONE";
522 if (this->shaping_ == GAUSSIAN_BT_0_3) {
523 shaping = "GAUSSIAN_BT_0_3";
524 } else if (this->shaping_ == GAUSSIAN_BT_0_5) {
525 shaping = "GAUSSIAN_BT_0_5";
526 } else if (this->shaping_ == GAUSSIAN_BT_0_7) {
527 shaping = "GAUSSIAN_BT_0_7";
528 } else if (this->shaping_ == GAUSSIAN_BT_1_0) {
529 shaping = "GAUSSIAN_BT_1_0";
530 }
531 ESP_LOGCONFIG(TAG,
532 " Modulation: FSK\n"
533 " Deviation: %" PRIu32 " Hz\n"
534 " Shaping: %s\n"
535 " Preamble Size: %" PRIu16 "\n"
536 " Preamble Detect: %" PRIu16 "\n"
537 " Bitrate: %" PRIu32 "b/s",
538 this->deviation_, shaping, this->preamble_size_, this->preamble_detect_, this->bitrate_);
539 } else if (this->modulation_ == PACKET_TYPE_LORA) {
540 const char *cr = "4/8";
541 if (this->coding_rate_ == LORA_CR_4_5) {
542 cr = "4/5";
543 } else if (this->coding_rate_ == LORA_CR_4_6) {
544 cr = "4/6";
545 } else if (this->coding_rate_ == LORA_CR_4_7) {
546 cr = "4/7";
547 }
548 ESP_LOGCONFIG(TAG,
549 " Modulation: LORA\n"
550 " Spreading Factor: %" PRIu8 "\n"
551 " Coding Rate: %s\n"
552 " Preamble Size: %" PRIu16,
553 this->spreading_factor_, cr, this->preamble_size_);
554 }
555 if (!this->sync_value_.empty()) {
556 char hex_buf[17]; // 8 bytes max = 16 hex chars + null
557 ESP_LOGCONFIG(TAG, " Sync Value: 0x%s",
558 format_hex_to(hex_buf, this->sync_value_.data(), this->sync_value_.size()));
559 }
560 ESP_LOGCONFIG(TAG, " Whitening Enable: %s", TRUEFALSE(this->whitening_enable_));
561 if (this->whitening_enable_) {
562 ESP_LOGCONFIG(TAG, " Whitening Initial: 0x%03x", this->whitening_initial_);
563 }
564}
565
566} // namespace esphome::sx126x
BedjetMode mode
BedJet operating mode.
uint8_t status
Definition bl0942.h:8
void feed_wdt()
Feed the task watchdog.
void mark_failed()
Mark this component as failed.
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
bool is_ready() const
void disable_loop()
Disable this component's loop.
virtual void setup()=0
virtual void digital_write(bool value)=0
virtual bool is_internal()
Only the platform pin class behind the InternalGPIOPin alias may return true: callers static_cast to ...
Definition gpio_pin.h:87
virtual bool digital_read()=0
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
Definition automation.h:556
uint8_t read_fifo_(uint8_t offset, std::vector< uint8_t > &packet)
Definition sx126x.cpp:33
void write_opcode_(uint8_t opcode, uint8_t *data, uint8_t size)
Definition sx126x.cpp:70
std::vector< uint8_t > sync_value_
Definition sx126x.h:125
std::vector< SX126xListener * > listeners_
Definition sx126x.h:123
size_t get_max_packet_size()
Definition sx126x.cpp:280
void set_mode_standby(SX126xStandbyMode mode)
Definition sx126x.cpp:485
SX126xError transmit_packet(const uint8_t *data, size_t len)
Definition sx126x.cpp:316
static void gpio_intr(SX126x *arg)
Definition sx126x.cpp:107
Trigger< std::vector< uint8_t >, float, float > packet_trigger_
Definition sx126x.h:122
uint8_t read_opcode_(uint8_t opcode, uint8_t *data, uint8_t size)
Definition sx126x.cpp:58
void dump_config() override
Definition sx126x.cpp:503
void write_fifo_(uint8_t offset, const uint8_t *data, size_t len)
Definition sx126x.cpp:46
void read_register_(uint16_t reg, uint8_t *data, uint8_t size)
Definition sx126x.cpp:81
void write_register_(uint16_t reg, uint8_t *data, uint8_t size)
Definition sx126x.cpp:94
uint16_t crc_polynomial_
Definition sx126x.h:134
uint16_t preamble_size_
Definition sx126x.h:138
void loop() override
Definition sx126x.cpp:372
void set_packet_params_(uint8_t payload_length)
Definition sx126x.cpp:287
void call_listeners_(const std::vector< uint8_t > &packet, float rssi, float snr)
Definition sx126x.cpp:365
std::vector< uint8_t > packet_
Definition sx126x.h:124
uint16_t preamble_detect_
Definition sx126x.h:137
void setup() override
Definition sx126x.cpp:109
uint16_t whitening_initial_
Definition sx126x.h:136
uint32_t payload_length_
Definition sx126x.h:132
uint8_t spreading_factor_
Definition sx126x.h:147
void set_mode_sleep(bool cold=false)
Definition sx126x.cpp:478
uint16_t preamble_size
int ret
uint8_t duration
Definition msa3xx.h:0
@ INTERRUPT_RISING_EDGE
Definition gpio_pin.h:52
ESPHOME_LOG_TAG(TAG, "sx126x_transport")
@ RADIO_SET_MODULATIONPARAMS
Definition sx126x_reg.h:31
@ RADIO_SET_LORASYMBTIMEOUT
Definition sx126x_reg.h:50
const void size_t len
Definition hal.h:68
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
Definition hal.cpp:48
uint16_t size
Definition helpers.cpp:34
void HOT delay(uint32_t ms)
Definition hal.cpp:85
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:25
char * format_hex_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length)
Format byte array as lowercase hex to buffer (base implementation).
Definition helpers.cpp:428
Application App
Global storage of Application pointer - only one Application can exist.
static void uint32_t