SX1276 implementation of RadioDriver.
More...
#include <radio_sx1276.h>
|
| | RadioSX1276 (SpiAccess *spi, InternalGPIOPin *rst_pin, InternalGPIOPin *dio0_pin, InternalGPIOPin *dio4_pin, uint8_t tx_power, uint8_t pa_pin) |
| bool | init () override |
| | Initialize the SX1276 radio (reset, calibrate, configure registers).
|
| bool | send_packet (const uint8_t *data, uint8_t len, const RadioTxConfig &tx_config) override |
| | Transmit a frame with specified frequency and preamble.
|
| bool | wait_for_packet (RadioRxPacket &packet, uint32_t timeout_ms) override |
| | Blocking wait for a packet with timeout.
|
| bool | check_for_packet (RadioRxPacket &packet) override |
| | Non‑blocking check for a received packet (called from loop).
|
| void | change_frequency (uint32_t freq_hz) override |
| | Change RF frequency using fast hop (no standby needed).
|
| int16_t | read_rssi () override |
| | Read instantaneous RSSI (dBm) while in RX mode (used for LBT).
|
| void | set_mode_rx () override |
| | Switch radio into continuous receive mode.
|
| void | set_mode_standby () override |
| | Switch radio into standby mode.
|
| bool | is_failed () const override |
| | Returns true if the radio failed to initialize or encountered a fatal error.
|
| const char * | chip_name () const override |
| | Get a human‑readable chip name.
|
| void | dump_debug () override |
| | Dump radio‑specific debug info to log.
|
| | RadioDriver (InternalGPIOPin *rst_pin=nullptr) |
| virtual | ~RadioDriver ()=default |
| uint32_t | get_current_freq () const |
| | Get the current RF frequency.
|
| const RadioCaptureInfo & | get_last_capture () const |
| | Get the most recent radio capture info.
|
| bool | is_dio_fired () const |
| | Set by the ISR when DIO fires.
|
| void | clear_dio_fired () |
| void | mark_dio_fired_from_isr () |
|
| uint8_t | read_register_ (uint8_t reg) |
| | Read an SX1276 register over SPI.
|
| void | write_register_ (uint8_t reg, uint8_t value) |
| | Write an SX1276 register over SPI.
|
| void | set_mode_ (uint8_t mode) |
| | Set the operating mode (sleep/standby/tx/rx) and wait for mode completion.
|
| void | configure_radio_ () |
| | Perform full radio configuration (called during init).
|
| void | run_image_cal_ () |
| | Run image calibration routine (required after reset).
|
| bool | poll_until_payload_ready_ (uint32_t timeout_ms, bool &saw_dio0, uint8_t &irq1, uint8_t &irq2) |
| | Wait until FIFO payload is ready (polling for TX/RX readiness).
|
| uint8_t | read_fifo_packet_ (uint8_t *buf, uint8_t buf_size) |
| | Read a packet from the RX FIFO into a buffer.
|
| void | fill_capture_info_ (bool blocking_wait, uint8_t irq1, uint8_t irq2, uint8_t rssi, const uint8_t *raw, uint8_t raw_len, const uint8_t *frame, uint8_t frame_len) |
| | Populate last_capture_ from raw telemetry.
|
| void | clear_last_capture_ () |
| | Clear the last capture info (resets diagnostic buffer).
|
| void | prepare_blocking_receive_ (RadioRxPacket &packet) |
| | Common preamble for blocking receive: clear diagnostics and output packet.
|
| void | prepare_nonblocking_receive_ (RadioRxPacket &packet) |
| | Common preamble for non‑blocking receive: clear diagnostics, output packet, and DIO latch.
|
| void | reset_hardware_ () |
| | Hardware reset sequence common to all SX chips.
|
| void | populate_capture_base_ (bool blocking_wait, uint32_t freq_hz, int16_t rssi_dbm, const uint8_t *raw, uint8_t raw_len, const uint8_t *frame, uint8_t frame_len) |
| | Populate the common fields of RadioCaptureInfo from raw telemetry.
|
SX1276 implementation of RadioDriver.
Manages the SX1276 via SPI using the SpiAccess interface. Configures the chip in FSK mode with IoHomeOn for hardware CRC and IO‑Homecontrol packet framing.
Definition at line 75 of file radio_sx1276.h.
◆ RadioSX1276()
| esphome::home_io_control::RadioSX1276::RadioSX1276 |
( |
SpiAccess * | spi, |
|
|
InternalGPIOPin * | rst_pin, |
|
|
InternalGPIOPin * | dio0_pin, |
|
|
InternalGPIOPin * | dio4_pin, |
|
|
uint8_t | tx_power, |
|
|
uint8_t | pa_pin ) |
|
inline |
◆ change_frequency()
| void esphome::home_io_control::RadioSX1276::change_frequency |
( |
uint32_t | freq_hz | ) |
|
|
overridevirtual |
◆ check_for_packet()
| bool esphome::home_io_control::RadioSX1276::check_for_packet |
( |
RadioRxPacket & | packet | ) |
|
|
overridevirtual |
◆ chip_name()
| const char * esphome::home_io_control::RadioSX1276::chip_name |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
◆ configure_radio_()
| void esphome::home_io_control::RadioSX1276::configure_radio_ |
( |
| ) |
|
|
protected |
Perform full radio configuration (called during init).
Definition at line 124 of file radio_sx1276.cpp.
◆ dump_debug()
| void esphome::home_io_control::RadioSX1276::dump_debug |
( |
| ) |
|
|
overridevirtual |
◆ fill_capture_info_()
| void esphome::home_io_control::RadioSX1276::fill_capture_info_ |
( |
bool | blocking_wait, |
|
|
uint8_t | irq1, |
|
|
uint8_t | irq2, |
|
|
uint8_t | rssi, |
|
|
const uint8_t * | raw, |
|
|
uint8_t | raw_len, |
|
|
const uint8_t * | frame, |
|
|
uint8_t | frame_len ) |
|
protected |
Populate last_capture_ from raw telemetry.
- Parameters
-
| blocking_wait | if this was a blocking receive. |
| irq1 | IRQ flags 1. |
| irq2 | IRQ flags 2. |
| rssi | RSSI value. |
| raw | Pointer to raw bytes (may be nullptr). |
| raw_len | Length of raw buffer. |
| frame | Pointer to parsed frame bytes (may be nullptr). |
| frame_len | Length of parsed frame. |
Definition at line 72 of file radio_sx1276.cpp.
◆ gpio_intr()
| void IRAM_ATTR esphome::home_io_control::RadioSX1276::gpio_intr |
( |
RadioSX1276 * | arg | ) |
|
|
staticprotected |
DIO0 ISR — sets dio_fired flag. Runs in interrupt context.
Definition at line 70 of file radio_sx1276.cpp.
◆ init()
| bool esphome::home_io_control::RadioSX1276::init |
( |
| ) |
|
|
overridevirtual |
◆ is_failed()
| bool esphome::home_io_control::RadioSX1276::is_failed |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
◆ poll_until_payload_ready_()
| bool esphome::home_io_control::RadioSX1276::poll_until_payload_ready_ |
( |
uint32_t | timeout_ms, |
|
|
bool & | saw_dio0, |
|
|
uint8_t & | irq1, |
|
|
uint8_t & | irq2 ) |
|
protected |
Wait until FIFO payload is ready (polling for TX/RX readiness).
- Parameters
-
| timeout_ms | How long to wait. |
| saw_dio0 | Output: true if DIO0 fired. |
| irq1 | Output: IRQ flags 1. |
| irq2 | Output: IRQ flags 2. |
- Returns
- true if payload ready before timeout; false otherwise.
Definition at line 246 of file radio_sx1276.cpp.
◆ read_fifo_packet_()
| uint8_t esphome::home_io_control::RadioSX1276::read_fifo_packet_ |
( |
uint8_t * | buf, |
|
|
uint8_t | buf_size ) |
|
protected |
Read a packet from the RX FIFO into a buffer.
- Parameters
-
| buf | Output buffer. |
| buf_size | Size of buf. |
- Returns
- Number of bytes read.
Definition at line 270 of file radio_sx1276.cpp.
◆ read_register_()
| uint8_t esphome::home_io_control::RadioSX1276::read_register_ |
( |
uint8_t | reg | ) |
|
|
protected |
Read an SX1276 register over SPI.
- Parameters
-
| reg | Register address (7 bits, MSB clear for read). |
- Returns
- Register value.
Definition at line 21 of file radio_sx1276.cpp.
◆ read_rssi()
| int16_t esphome::home_io_control::RadioSX1276::read_rssi |
( |
| ) |
|
|
overridevirtual |
◆ run_image_cal_()
| void esphome::home_io_control::RadioSX1276::run_image_cal_ |
( |
| ) |
|
|
protected |
Run image calibration routine (required after reset).
Definition at line 57 of file radio_sx1276.cpp.
◆ send_packet()
| bool esphome::home_io_control::RadioSX1276::send_packet |
( |
const uint8_t * | data, |
|
|
uint8_t | len, |
|
|
const RadioTxConfig & | tx_config ) |
|
overridevirtual |
Transmit a frame with specified frequency and preamble.
- Parameters
-
| data | Pointer to payload bytes. |
| len | Payload length. |
| tx_config | Transmission config (frequency, preamble). |
- Returns
- true if transmit succeeded.
Implements esphome::home_io_control::RadioDriver.
Definition at line 206 of file radio_sx1276.cpp.
◆ set_mode_()
| void esphome::home_io_control::RadioSX1276::set_mode_ |
( |
uint8_t | mode | ) |
|
|
protected |
Set the operating mode (sleep/standby/tx/rx) and wait for mode completion.
- Parameters
-
| mode | One of MODE_SLEEP, MODE_STDBY, MODE_TX, or MODE_RX. |
Definition at line 38 of file radio_sx1276.cpp.
◆ set_mode_rx()
| void esphome::home_io_control::RadioSX1276::set_mode_rx |
( |
| ) |
|
|
overridevirtual |
◆ set_mode_standby()
| void esphome::home_io_control::RadioSX1276::set_mode_standby |
( |
| ) |
|
|
overridevirtual |
◆ wait_for_packet()
| bool esphome::home_io_control::RadioSX1276::wait_for_packet |
( |
RadioRxPacket & | packet, |
|
|
uint32_t | timeout_ms ) |
|
overridevirtual |
Blocking wait for a packet with timeout.
- Parameters
-
| packet | Output: received packet (freq, len, data). |
| timeout_ms | Maximum time to wait. |
- Returns
- true if a packet was received; false on timeout.
Implements esphome::home_io_control::RadioDriver.
Definition at line 277 of file radio_sx1276.cpp.
◆ write_register_()
| void esphome::home_io_control::RadioSX1276::write_register_ |
( |
uint8_t | reg, |
|
|
uint8_t | value ) |
|
protected |
Write an SX1276 register over SPI.
- Parameters
-
| reg | Register address (7 bits, MSB set for write). |
| value | Byte to write. |
Definition at line 29 of file radio_sx1276.cpp.
◆ dio0_pin_
| InternalGPIOPin* esphome::home_io_control::RadioSX1276::dio0_pin_ |
|
protected |
◆ dio4_pin_
| InternalGPIOPin* esphome::home_io_control::RadioSX1276::dio4_pin_ |
|
protected |
◆ failed_
| bool esphome::home_io_control::RadioSX1276::failed_ {false} |
|
protected |
◆ pa_pin_
| uint8_t esphome::home_io_control::RadioSX1276::pa_pin_ |
|
protected |
◆ spi_
| SpiAccess* esphome::home_io_control::RadioSX1276::spi_ |
|
protected |
◆ tx_power_
| uint8_t esphome::home_io_control::RadioSX1276::tx_power_ |
|
protected |
The documentation for this class was generated from the following files: