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

Abstract radio driver for IO-Homecontrol. More...

#include <radio_interface.h>

Inheritance diagram for esphome::home_io_control::RadioDriver:
Collaboration diagram for esphome::home_io_control::RadioDriver:

Public Member Functions

 RadioDriver (InternalGPIOPin *rst_pin=nullptr)
virtual ~RadioDriver ()=default
virtual bool init ()=0
 Initialize the radio hardware. Returns true on success.
virtual bool send_packet (const uint8_t *data, uint8_t len, const RadioTxConfig &tx_config)=0
 Send a packet using the specified carrier frequency and preamble settings.
virtual bool wait_for_packet (RadioRxPacket &packet, uint32_t timeout_ms)=0
 Wait (blocking) for a packet with timeout.
virtual bool check_for_packet (RadioRxPacket &packet)=0
 Non-blocking check for a received packet.
virtual int16_t read_rssi ()=0
 Read instantaneous RSSI (in dBm) while in RX mode.
virtual void change_frequency (uint32_t freq_hz)=0
 Change the carrier frequency using fast hop (no standby transition needed).
virtual void set_mode_rx ()=0
 Switch to continuous receive mode.
virtual void set_mode_standby ()=0
 Switch to standby mode.
virtual bool is_failed () const =0
 Returns true if the radio failed to initialize or encountered a fatal error.
virtual const char * chip_name () const =0
 Get a human‑readable chip name.
virtual void dump_debug ()
 Optional chip-specific diagnostics emitted from dump_config.
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

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.

Protected Attributes

uint32_t current_freq_ {FREQ_CH2}
RadioCaptureInfo last_capture_ {}
InternalGPIOPin * rst_pin_ {nullptr}
volatile bool dio_fired_ {false}

Detailed Description

Abstract radio driver for IO-Homecontrol.

Encapsulates all chip-specific operations: initialization, packet TX/RX, frequency control, and mode switching. Concrete implementations (RadioSX1276, RadioSX1262) handle the register-level details for each chip.

Definition at line 91 of file radio_interface.h.

Constructor & Destructor Documentation

◆ RadioDriver()

esphome::home_io_control::RadioDriver::RadioDriver ( InternalGPIOPin * rst_pin = nullptr)
inlineexplicit

Definition at line 93 of file radio_interface.h.

◆ ~RadioDriver()

virtual esphome::home_io_control::RadioDriver::~RadioDriver ( )
virtualdefault

Member Function Documentation

◆ change_frequency()

virtual void esphome::home_io_control::RadioDriver::change_frequency ( uint32_t freq_hz)
pure virtual

Change the carrier frequency using fast hop (no standby transition needed).

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ check_for_packet()

virtual bool esphome::home_io_control::RadioDriver::check_for_packet ( RadioRxPacket & packet)
pure virtual

Non-blocking check for a received packet.

Called from loop(). Returns true if a packet was read into packet. Contract:

  • Returns false immediately if no DIO interrupt has fired.
  • On success: populates packet and last_capture_, returns true.
  • On failure: may populate last_capture_ for diagnostics, returns false.

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ chip_name()

virtual const char * esphome::home_io_control::RadioDriver::chip_name ( ) const
nodiscardpure virtual

Get a human‑readable chip name.

Returns
"sx1276" or "sx1262".

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ clear_dio_fired()

void esphome::home_io_control::RadioDriver::clear_dio_fired ( )
inline

Definition at line 161 of file radio_interface.h.

◆ clear_last_capture_()

void esphome::home_io_control::RadioDriver::clear_last_capture_ ( )
inlineprotected

Clear the last capture info (resets diagnostic buffer).

Definition at line 182 of file radio_interface.h.

◆ dump_debug()

virtual void esphome::home_io_control::RadioDriver::dump_debug ( )
inlinevirtual

Optional chip-specific diagnostics emitted from dump_config.

Reimplemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

Definition at line 142 of file radio_interface.h.

◆ get_current_freq()

uint32_t esphome::home_io_control::RadioDriver::get_current_freq ( ) const
inlinenodiscard

Get the current RF frequency.

Returns
Frequency in Hz.

Definition at line 146 of file radio_interface.h.

◆ get_last_capture()

const RadioCaptureInfo & esphome::home_io_control::RadioDriver::get_last_capture ( ) const
inlinenodiscard

Get the most recent radio capture info.

Returns
const reference to RadioCaptureInfo.

Definition at line 149 of file radio_interface.h.

◆ init()

virtual bool esphome::home_io_control::RadioDriver::init ( )
pure virtual

Initialize the radio hardware. Returns true on success.

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ is_dio_fired()

bool esphome::home_io_control::RadioDriver::is_dio_fired ( ) const
inlinenodiscard

Set by the ISR when DIO fires.

Using access helpers instead of touching the flag directly keeps the ISR/main-loop handoff explicit and lets ESP32 builds use atomic storage.

Definition at line 153 of file radio_interface.h.

◆ is_failed()

virtual bool esphome::home_io_control::RadioDriver::is_failed ( ) const
nodiscardpure virtual

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

Returns
true on failure.

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ mark_dio_fired_from_isr()

void esphome::home_io_control::RadioDriver::mark_dio_fired_from_isr ( )
inline

Definition at line 171 of file radio_interface.h.

◆ populate_capture_base_()

void esphome::home_io_control::RadioDriver::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 )
inlineprotected

Populate the common fields of RadioCaptureInfo from raw telemetry.

Chip‑specific fields (rx_done, crc_error, irq_flags*, irq_status, packet_status, etc.) must be set by the derived driver after calling this helper.

Parameters
blocking_waitif this was a blocking receive.
freq_hzRF frequency of the capture.
rssi_dbmReceived signal strength.
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 213 of file radio_interface.h.

◆ prepare_blocking_receive_()

void esphome::home_io_control::RadioDriver::prepare_blocking_receive_ ( RadioRxPacket & packet)
inlineprotected

Common preamble for blocking receive: clear diagnostics and output packet.

Parameters
packetOutput packet buffer to zero and prepare.

Definition at line 186 of file radio_interface.h.

Here is the call graph for this function:

◆ prepare_nonblocking_receive_()

void esphome::home_io_control::RadioDriver::prepare_nonblocking_receive_ ( RadioRxPacket & packet)
inlineprotected

Common preamble for non‑blocking receive: clear diagnostics, output packet, and DIO latch.

Parameters
packetOutput packet buffer to zero and prepare.

Definition at line 193 of file radio_interface.h.

Here is the call graph for this function:

◆ read_rssi()

virtual int16_t esphome::home_io_control::RadioDriver::read_rssi ( )
pure virtual

Read instantaneous RSSI (in dBm) while in RX mode.

Used for listen-before-talk (LBT) carrier sense before transmitting.

Returns
RSSI in dBm (negative value).

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ reset_hardware_()

void esphome::home_io_control::RadioDriver::reset_hardware_ ( )
protected

Hardware reset sequence common to all SX chips.

Drives RST pin low → 10 ms → high → 10 ms. Called from derived driver init().

Definition at line 17 of file radio_interface.cpp.

◆ send_packet()

virtual bool esphome::home_io_control::RadioDriver::send_packet ( const uint8_t * data,
uint8_t len,
const RadioTxConfig & tx_config )
pure virtual

Send a packet using the specified carrier frequency and preamble settings.

The radio handles CRC automatically (IoHomeOn mode for SX1276).

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ set_mode_rx()

virtual void esphome::home_io_control::RadioDriver::set_mode_rx ( )
pure virtual

Switch to continuous receive mode.

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

◆ set_mode_standby()

virtual void esphome::home_io_control::RadioDriver::set_mode_standby ( )
pure virtual

◆ wait_for_packet()

virtual bool esphome::home_io_control::RadioDriver::wait_for_packet ( RadioRxPacket & packet,
uint32_t timeout_ms )
pure virtual

Wait (blocking) for a packet with timeout.

Returns true if a packet was received. Contract:

  • Clears last_capture_ and output packet before waiting.
  • On success: populates packet and last_capture_, returns true.
  • On timeout/failure: may populate last_capture_ for diagnostics, returns false.
  • Radio remains in RX mode on return (regardless of outcome).

Implemented in esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.

Member Data Documentation

◆ current_freq_

uint32_t esphome::home_io_control::RadioDriver::current_freq_ {FREQ_CH2}
protected

Definition at line 231 of file radio_interface.h.

◆ dio_fired_

volatile bool esphome::home_io_control::RadioDriver::dio_fired_ {false}
protected

Definition at line 238 of file radio_interface.h.

◆ last_capture_

RadioCaptureInfo esphome::home_io_control::RadioDriver::last_capture_ {}
protected

Definition at line 232 of file radio_interface.h.

◆ rst_pin_

InternalGPIOPin* esphome::home_io_control::RadioDriver::rst_pin_ {nullptr}
protected

Definition at line 233 of file radio_interface.h.


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