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