Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
esphome::home_io_control::RadioSX1276 Class Reference

SX1276 implementation of RadioDriver. More...

#include <radio_sx1276.h>

Inheritance diagram for esphome::home_io_control::RadioSX1276:
Collaboration diagram for esphome::home_io_control::RadioSX1276:

Public Member Functions

 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.
Public Member Functions inherited from esphome::home_io_control::RadioDriver
 RadioDriver (InternalGPIOPin *rst_pin=nullptr)
virtual ~RadioDriver ()=default
uint32_t get_current_freq () const
 Get the current RF frequency.
const RadioCaptureInfoget_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 ()

Protected Member Functions

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.
Protected Member Functions inherited from esphome::home_io_control::RadioDriver
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.

Static Protected Member Functions

static void gpio_intr (RadioSX1276 *arg)
 DIO0 ISR — sets dio_fired flag. Runs in interrupt context.

Protected Attributes

SpiAccessspi_
InternalGPIOPin * dio0_pin_
InternalGPIOPin * dio4_pin_
uint8_t tx_power_
uint8_t pa_pin_
bool failed_ {false}
Protected Attributes inherited from esphome::home_io_control::RadioDriver
uint32_t current_freq_ {FREQ_CH2}
RadioCaptureInfo last_capture_ {}
InternalGPIOPin * rst_pin_ {nullptr}
volatile bool dio_fired_ {false}

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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

Definition at line 77 of file radio_sx1276.h.

Here is the call graph for this function:

Member Function Documentation

◆ change_frequency()

void esphome::home_io_control::RadioSX1276::change_frequency ( uint32_t freq_hz)
overridevirtual

Change RF frequency using fast hop (no standby needed).

Parameters
freq_hzNew frequency in Hz.

Implements esphome::home_io_control::RadioDriver.

Definition at line 86 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ check_for_packet()

bool esphome::home_io_control::RadioSX1276::check_for_packet ( RadioRxPacket & packet)
overridevirtual

Non‑blocking check for a received packet (called from loop).

Parameters
packetOutput: received packet if any.
Returns
true if a packet was read; false if no interrupt fired.

Implements esphome::home_io_control::RadioDriver.

Definition at line 303 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ chip_name()

const char * esphome::home_io_control::RadioSX1276::chip_name ( ) const
inlinenodiscardoverridevirtual

Get a human‑readable chip name.

Returns
"sx1276" or "sx1262".

Implements esphome::home_io_control::RadioDriver.

Definition at line 117 of file radio_sx1276.h.

◆ 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.

Here is the call graph for this function:

◆ dump_debug()

void esphome::home_io_control::RadioSX1276::dump_debug ( )
overridevirtual

Dump radio‑specific debug info to log.

Reimplemented from esphome::home_io_control::RadioDriver.

Definition at line 328 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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_waitif this was a blocking receive.
irq1IRQ flags 1.
irq2IRQ flags 2.
rssiRSSI value.
rawPointer to raw bytes (may be nullptr).
raw_lenLength of raw buffer.
framePointer to parsed frame bytes (may be nullptr).
frame_lenLength of parsed frame.

Definition at line 72 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ init()

bool esphome::home_io_control::RadioSX1276::init ( )
overridevirtual

Initialize the SX1276 radio (reset, calibrate, configure registers).

Returns
true on success; false on failure (e.g., version check).

Implements esphome::home_io_control::RadioDriver.

Definition at line 98 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ is_failed()

bool esphome::home_io_control::RadioSX1276::is_failed ( ) const
inlinenodiscardoverridevirtual

Returns true if the radio failed to initialize or encountered a fatal error.

Returns
true on failure.

Implements esphome::home_io_control::RadioDriver.

Definition at line 115 of file radio_sx1276.h.

◆ 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_msHow long to wait.
saw_dio0Output: true if DIO0 fired.
irq1Output: IRQ flags 1.
irq2Output: IRQ flags 2.
Returns
true if payload ready before timeout; false otherwise.

Definition at line 246 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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
bufOutput buffer.
buf_sizeSize of buf.
Returns
Number of bytes read.

Definition at line 270 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ read_register_()

uint8_t esphome::home_io_control::RadioSX1276::read_register_ ( uint8_t reg)
protected

Read an SX1276 register over SPI.

Parameters
regRegister 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

Read instantaneous RSSI (dBm) while in RX mode (used for LBT).

Returns
RSSI in dBm (negative).

Implements esphome::home_io_control::RadioDriver.

Definition at line 94 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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
dataPointer to payload bytes.
lenPayload length.
tx_configTransmission config (frequency, preamble).
Returns
true if transmit succeeded.

Implements esphome::home_io_control::RadioDriver.

Definition at line 206 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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
modeOne of MODE_SLEEP, MODE_STDBY, MODE_TX, or MODE_RX.

Definition at line 38 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ set_mode_rx()

void esphome::home_io_control::RadioSX1276::set_mode_rx ( )
overridevirtual

Switch radio into continuous receive mode.

Implements esphome::home_io_control::RadioDriver.

Definition at line 54 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ set_mode_standby()

void esphome::home_io_control::RadioSX1276::set_mode_standby ( )
overridevirtual

Switch radio into standby mode.

Implements esphome::home_io_control::RadioDriver.

Definition at line 55 of file radio_sx1276.cpp.

Here is the call graph for this function:

◆ 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
packetOutput: received packet (freq, len, data).
timeout_msMaximum 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.

Here is the call graph for this function:

◆ write_register_()

void esphome::home_io_control::RadioSX1276::write_register_ ( uint8_t reg,
uint8_t value )
protected

Write an SX1276 register over SPI.

Parameters
regRegister address (7 bits, MSB set for write).
valueByte to write.

Definition at line 29 of file radio_sx1276.cpp.

Member Data Documentation

◆ dio0_pin_

InternalGPIOPin* esphome::home_io_control::RadioSX1276::dio0_pin_
protected

Definition at line 168 of file radio_sx1276.h.

◆ dio4_pin_

InternalGPIOPin* esphome::home_io_control::RadioSX1276::dio4_pin_
protected

Definition at line 169 of file radio_sx1276.h.

◆ failed_

bool esphome::home_io_control::RadioSX1276::failed_ {false}
protected

Definition at line 172 of file radio_sx1276.h.

◆ pa_pin_

uint8_t esphome::home_io_control::RadioSX1276::pa_pin_
protected

Definition at line 171 of file radio_sx1276.h.

◆ spi_

SpiAccess* esphome::home_io_control::RadioSX1276::spi_
protected

Definition at line 167 of file radio_sx1276.h.

◆ tx_power_

uint8_t esphome::home_io_control::RadioSX1276::tx_power_
protected

Definition at line 170 of file radio_sx1276.h.


The documentation for this class was generated from the following files: