17#include "esphome/core/hal.h"
207 [[nodiscard]]
virtual const char *
chip_name()
const = 0;
222#if defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
223 return this->
dio_fired_.load(std::memory_order_acquire);
232#if defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
233 this->
dio_fired_.store(
false, std::memory_order_release);
241#if defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
242 this->
dio_fired_.store(
true, std::memory_order_release);
282 uint8_t raw_len,
const uint8_t *frame, uint8_t frame_len) {
289 if (raw !=
nullptr && raw_len > 0) {
291 memcpy(this->
last_capture_.raw, raw, this->last_capture_.raw_len);
293 if (frame !=
nullptr && frame_len > 0) {
295 memcpy(this->
last_capture_.frame, frame, this->last_capture_.frame_len);
303#if defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
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.
void clear_last_capture_()
Clear the last capture info (resets diagnostic buffer).
InternalGPIOPin * rst_pin_
uint32_t get_current_freq() const
Get the current RF frequency.
RadioDriver(InternalGPIOPin *rst_pin=nullptr)
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...
void mark_dio_fired_from_isr()
void reset_hardware_()
Shared hardware reset sequence for chips with an active-low RST pin.
virtual uint16_t response_preamble() const
Return the preamble length for response/continuation frames.
virtual uint16_t discovery_hop_slice_ms(const TuningConfig &tuning) const =0
Per-channel dwell while pairing discovery hops across channels.
virtual bool is_sync_detected()=0
Check if sync word has been detected (while in RX).
virtual void change_frequency(uint32_t freq_hz)=0
Change the carrier frequency using fast hop (no standby transition needed).
virtual bool is_failed() const =0
Returns true if the radio failed to initialize or encountered a fatal error.
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.
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 const char * chip_name() const =0
Get a human‑readable chip name.
virtual bool init()=0
Initialize the radio hardware. Returns true on success.
virtual void set_mode_standby()=0
Switch to standby mode.
virtual ~RadioDriver()=default
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 void dump_debug()
Optional chip-specific diagnostics emitted from dump_config.
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.
RadioCaptureInfo last_capture_
void prepare_nonblocking_receive_(RadioRxPacket &packet)
Common preamble for non‑blocking receive: clear diagnostics, output packet, and DIO latch.
virtual bool wait_for_packet(RadioRxPacket &packet, uint32_t timeout_ms)=0
Wait (blocking) for a packet with timeout.
void prepare_blocking_receive_(RadioRxPacket &packet)
Common preamble for blocking receive: clear diagnostics and output packet.
virtual void set_mode_rx()=0
Switch to continuous receive mode.
virtual bool is_preamble_detected()=0
Check if preamble has been detected (while in RX).
Interface for SPI bus access.
virtual void spi_enable()=0
Enable the SPI bus (assert CS low).
virtual void spi_write(uint8_t data)=0
Write one byte (MOSI only, MISO ignored).
virtual ~SpiAccess()=default
virtual uint8_t spi_transfer(uint8_t data)=0
Transfer one byte full‑duplex (MOSI→MISO).
virtual void spi_disable()=0
Disable the SPI bus (deassert CS).
virtual uint8_t spi_read()=0
Read one byte (MISO only, MOSI driven with 0).
static constexpr uint32_t FREQ_CH2
Channel 2: 868.95 MHz (1W and 2W, TX channel).
static constexpr uint16_t SHORT_PREAMBLE
8 bytes for response/continuation frames
constexpr uint8_t RADIO_PACKET_BUFFER_SIZE
Scratch buffer size for raw radio packets and recovered frames.
static constexpr int32_t RESPONSE_CHANNEL_WAIT_MS
Per-channel dwell while waiting for an exchange response.
IO-Homecontrol 2W frame container: control bytes, IoFrame and (de)serialization.
Physical-layer radio and timing parameters for the IO-Homecontrol protocol.
Diagnostic capture from a radio operation.
uint32_t timestamp_ms
Timestamp of capture (millis).
uint8_t frame_len
Number of valid bytes in frame[].
uint16_t irq_status
Raw IRQ status register value.
uint8_t packet_status
Packet status byte (chip-specific).
uint8_t irq_flags2
IRQ flags group 2 (chip-specific, includes CRC flag).
bool blocking_wait
True if captured during a blocking wait.
bool crc_error
True if a CRC error was detected.
uint8_t frame[RADIO_PACKET_BUFFER_SIZE]
Parsed protocol frame bytes.
bool valid
True if capture is valid.
uint8_t reported_len
Length reported by the radio chip.
bool rx_done
True if RxDone IRQ fired.
uint32_t freq_hz
RF frequency of capture (Hz).
uint8_t irq_flags1
IRQ flags group 1 (chip-specific).
uint8_t raw[RADIO_PACKET_BUFFER_SIZE]
Raw radio buffer bytes.
uint8_t raw_len
Number of valid bytes in raw[].
int16_t rssi_dbm
Received signal strength (dBm).
uint8_t rx_offset
RX buffer offset where the frame starts (0 for chips without offset reporting).
Raw packet received from the radio.
uint8_t len
Length of packet in bytes.
uint32_t freq_hz
Frequency the packet was received on (Hz).
uint8_t data[RADIO_PACKET_BUFFER_SIZE]
Raw packet data buffer.
Configuration for transmitting a packet: carrier frequency and preamble length.
uint16_t preamble_len
Preamble length in symbol periods (bytes).
uint32_t freq_hz
Carrier frequency in Hz.
All runtime tunable parameters for pairing and radio diagnostics.
Runtime tuning configuration for pairing and radio diagnostics.