|
Home IO Control
ESPHome add-on for IO-Homecontrol devices
|
Abstract radio driver for IO-Homecontrol. More...
#include <radio_interface.h>
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 bool | is_sync_detected ()=0 |
| Check if sync word has been detected (while in RX). | |
| virtual bool | is_preamble_detected ()=0 |
| Check if preamble has been detected (while in RX). | |
| virtual uint16_t | response_preamble () const |
| Return the preamble length for response/continuation frames. | |
| virtual void | apply_tuning (const TuningConfig &tuning) |
| Apply runtime tuning parameters to the driver. | |
| virtual uint32_t | exchange_wait_slice_ms () const |
| Per-channel dwell while waiting for an authenticated exchange response. | |
| virtual uint16_t | discovery_hop_slice_ms (const TuningConfig &tuning) const =0 |
| Per-channel dwell while pairing discovery hops across channels. | |
| virtual bool | has_fast_tx_rx_turnaround () const =0 |
| Whether the chip re-enters RX fast enough after a TX to catch an immediate reply through the standard exchange wait. | |
| 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 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 () |
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_ () |
| Shared hardware reset sequence for chips with an active-low RST pin. | |
| 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} |
Abstract radio driver for IO-Homecontrol.
Encapsulates all chip-specific operations: initialization, packet TX/RX, frequency control, and mode switching. Concrete implementations (RadioSX1276, RadioSX1262, RadioLR1121) handle the register-level details for each chip.
Definition at line 97 of file radio_interface.h.
|
inlineexplicit |
Definition at line 99 of file radio_interface.h.
|
virtualdefault |
|
inlinevirtual |
Apply runtime tuning parameters to the driver.
Each driver consumes only the fields it understands; the default is a no-op for chips with no runtime-tunable radio parameters. This keeps the hub free of chip-specific tuning knowledge — it hands over the whole config and lets the driver pick what it needs.
| tuning | Current tuning configuration. |
Reimplemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
Definition at line 160 of file radio_interface.h.
|
pure virtual |
Change the carrier frequency using fast hop (no standby transition needed).
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
pure virtual |
Non-blocking check for a received packet.
Called from loop(). Returns true if a packet was read into packet. Contract:
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
nodiscardpure virtual |
Get a human‑readable chip name.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
inline |
Definition at line 229 of file radio_interface.h.
|
inlineprotected |
Clear the last capture info (resets diagnostic buffer).
Definition at line 250 of file radio_interface.h.
|
nodiscardpure virtual |
Per-channel dwell while pairing discovery hops across channels.
The right dwell is inherently chip-specific — it depends on how fast the chip can retune (fast hop vs. a standby→retune→RX cycle) — so there is no generic default: each driver must return its value, normally from its user-facing tuning field.
| tuning | Current tuning configuration. |
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
inlinevirtual |
Optional chip-specific diagnostics emitted from dump_config.
Reimplemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
Definition at line 210 of file radio_interface.h.
|
inlinenodiscardvirtual |
Per-channel dwell while waiting for an authenticated exchange response.
The default RESPONSE_CHANNEL_WAIT_MS slice is correct for the baseline protocol flow and pairing. A driver overrides this with a longer dwell when its RX path needs more margin to catch the final post-auth response before hopping away (see the concrete drivers for the chip-specific rationale).
Reimplemented in esphome::home_io_control::RadioLR1121, and esphome::home_io_control::RadioSX1262.
Definition at line 169 of file radio_interface.h.
|
inlinenodiscard |
Get the current RF frequency.
Definition at line 214 of file radio_interface.h.
|
inlinenodiscard |
Get the most recent radio capture info.
Definition at line 217 of file radio_interface.h.
|
nodiscardpure virtual |
Whether the chip re-enters RX fast enough after a TX to catch an immediate reply through the standard exchange wait.
Some chips need a standby/settle cycle between TX and RX, so a device's immediate response (e.g. the pairing key-confirm 0x33) can arrive while the receiver is still settling and be lost. Callers choose between the standard exchange wait and a dedicated wait-and-retrigger strategy based on this. There is no safe generic default — each driver must declare it.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
pure virtual |
Initialize the radio hardware. Returns true on success.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
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 221 of file radio_interface.h.
|
nodiscardpure virtual |
Returns true if the radio failed to initialize or encountered a fatal error.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
pure virtual |
Check if preamble has been detected (while in RX).
Used together with sync detection to gate frequency hopping.
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
pure virtual |
Check if sync word has been detected (while in RX).
Used to gate frequency hopping — prevents hopping away mid-frame.
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
inline |
Definition at line 239 of file radio_interface.h.
|
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.
| blocking_wait | if this was a blocking receive. |
| freq_hz | RF frequency of the capture. |
| rssi_dbm | Received signal strength. |
| 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 281 of file radio_interface.h.
|
inlineprotected |
Common preamble for blocking receive: clear diagnostics and output packet.
| packet | Output packet buffer to zero and prepare. |
Definition at line 254 of file radio_interface.h.
|
inlineprotected |
Common preamble for non‑blocking receive: clear diagnostics, output packet, and DIO latch.
| packet | Output packet buffer to zero and prepare. |
Definition at line 261 of file radio_interface.h.
|
pure virtual |
Read instantaneous RSSI (in dBm) while in RX mode.
Used for listen-before-talk (LBT) carrier sense before transmitting.
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
protected |
Shared hardware reset sequence for chips with an active-low RST pin.
Drives RST pin low → 10 ms → high → 10 ms. Called from derived driver init().
Definition at line 18 of file radio_interface.cpp.
|
inlinenodiscardvirtual |
Return the preamble length for response/continuation frames.
Callers use this instead of hardcoding SHORT_PREAMBLE for any frame sent as an immediate reply within an exchange (challenge responses, key transfers, and any future non-START continuation frames — i.e. tight RX→TX turnaround).
The default is the protocol's standard SHORT_PREAMBLE. Drivers whose TX waveform gives the peer device less synchronization margin override this with a longer preamble (see the concrete drivers for the chip-specific rationale).
Reimplemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
Definition at line 151 of file radio_interface.h.
|
pure virtual |
Send a packet using the specified carrier frequency and preamble settings.
The driver is responsible for appending the protocol CRC on the air (in hardware or software, depending on the chip).
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
pure virtual |
Switch to continuous receive mode.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
pure virtual |
Switch to standby mode.
Implemented in esphome::home_io_control::RadioLR1121, esphome::home_io_control::RadioSX1262, and esphome::home_io_control::RadioSX1276.
|
pure virtual |
Wait (blocking) for a packet with timeout.
Returns true if a packet was received. Contract:
Implemented in esphome::home_io_control::RadioSX1276, and esphome::home_io_control::SoftPhyDriverBase.
|
protected |
Definition at line 299 of file radio_interface.h.
|
protected |
Definition at line 306 of file radio_interface.h.
|
protected |
Definition at line 300 of file radio_interface.h.
|
protected |
Definition at line 301 of file radio_interface.h.