idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::radio::sx126x Class Referencefinal

Concrete LoRa radio driver for the Semtech SX126x family. More...

Inheritance diagram for idfxx::radio::sx126x:
idfxx::radio::lora_transceiver

Classes

struct  cad_params
 SX126x-specific channel-activity-detection parameters. More...
 
struct  config
 Configuration for an SX126x driver instance. More...
 
struct  tcxo_config
 TCXO configuration applied through DIO3. More...
 

Public Types

enum class  chip_variant : uint8_t {
  sx1261 ,
  sx1262 ,
  sx1268
}
 SX126x family chip variant. More...
 
enum class  regulator : uint8_t {
  ldo = 0x00 ,
  dc_dc = 0x01
}
 Voltage regulator selection. More...
 
enum class  standby_clock : uint8_t {
  rc ,
  xosc
}
 Clock source kept running in standby mode. More...
 
enum class  sleep_mode : uint8_t {
  warm ,
  cold
}
 Sleep-mode configuration retention. More...
 
enum class  cad_symbols : uint8_t {
  sym_1 = 0x00 ,
  sym_2 = 0x01 ,
  sym_4 = 0x02 ,
  sym_8 = 0x03 ,
  sym_16 = 0x04
}
 Number of symbols a CAD (channel activity detection) operates on. More...
 
using irq_flag = sx126x_irq_flag
 IRQ-register bitfield enumeration. See sx126x_irq_flag.
 

Public Member Functions

 sx126x (spi::master_bus &bus, config config)
 Constructs a new SX126x driver on the given SPI bus.
 
 ~sx126x () override
 
 sx126x (const sx126x &)=delete
 
sx126xoperator= (const sx126x &)=delete
 
 sx126x (sx126x &&other) noexcept
 
sx126xoperator= (sx126x &&other) noexcept
 
chip_variant variant () const noexcept
 Returns the configured chip variant.
 
spi::master_devicespi () noexcept
 Returns the underlying SPI device for advanced/diagnostic use.
 
void standby (standby_clock clock)
 Puts the radio in standby mode with the selected clock source.
 
void sleep (sleep_mode mode)
 Puts the radio in sleep mode with the selected retention.
 
result< void > try_standby (standby_clock clock)
 Puts the radio in standby mode with the selected clock source.
 
result< void > try_sleep (sleep_mode mode)
 Puts the radio in sleep mode with the selected retention.
 
void set_sync_word (uint16_t sync_word)
 Sets a raw 16-bit LoRa sync word.
 
void set_cad_params (cad_params params)
 Sets CAD detection parameters.
 
std::optional< rx_infoadopt_pending ()
 Drains an IRQ the chip latched while no driver was running.
 
flags< irq_flagirq_status ()
 Returns the current IRQ-register status.
 
void clear_irq_status (flags< irq_flag > mask)
 Clears the specified IRQ bits.
 
result< std::optional< rx_info > > try_adopt_pending ()
 Drains an IRQ the chip latched while no driver was running.
 
result< void > try_set_sync_word (uint16_t sync_word)
 Sets a raw 16-bit LoRa sync word.
 
result< void > try_set_cad_params (cad_params params)
 Sets CAD detection parameters.
 
result< flags< irq_flag > > try_irq_status ()
 Returns the current IRQ-register status.
 
result< void > try_clear_irq_status (flags< irq_flag > mask)
 Clears the specified IRQ bits.
 
void write_command (uint8_t opcode, std::span< const uint8_t > params)
 Sends a command opcode with parameter bytes.
 
void read_command (uint8_t opcode, std::span< uint8_t > response)
 Sends a command opcode and reads the response bytes.
 
void write_register (uint16_t addr, std::span< const uint8_t > data)
 Writes one or more chip registers.
 
void read_register (uint16_t addr, std::span< uint8_t > data)
 Reads one or more chip registers.
 
void write_buffer (uint8_t offset, std::span< const uint8_t > data)
 Writes the chip's data buffer at the specified offset.
 
void read_buffer (uint8_t offset, std::span< uint8_t > data)
 Reads the chip's data buffer at the specified offset.
 
result< void > try_write_command (uint8_t opcode, std::span< const uint8_t > params)
 Result variant of write_command.
 
result< void > try_read_command (uint8_t opcode, std::span< uint8_t > response)
 Result variant of read_command.
 
result< void > try_write_register (uint16_t addr, std::span< const uint8_t > data)
 Result variant of write_register.
 
result< void > try_read_register (uint16_t addr, std::span< uint8_t > data)
 Result variant of read_register.
 
result< void > try_write_buffer (uint8_t offset, std::span< const uint8_t > data)
 Result variant of write_buffer.
 
result< void > try_read_buffer (uint8_t offset, std::span< uint8_t > data)
 Result variant of read_buffer.
 
void sleep ()
 Puts the radio in its lowest-power sleep mode.
 
void standby ()
 Puts the radio in standby mode.
 
result< void > try_sleep ()
 Puts the radio in its lowest-power sleep mode.
 
result< void > try_standby ()
 Puts the radio in standby mode.
 
void set_sync_word (lora_network network)
 Selects the LoRa network by setting the sync word.
 
result< void > try_set_sync_word (lora_network network)
 Selects the LoRa network by setting the sync word.
 
- Public Member Functions inherited from idfxx::radio::lora_transceiver
virtual ~lora_transceiver ()=default
 
 lora_transceiver (const lora_transceiver &)=delete
 
lora_transceiveroperator= (const lora_transceiver &)=delete
 
chip_mode current_mode () const noexcept
 Returns the radio's current high-level mode.
 
lora_modulation modulation () const noexcept
 Returns the configured LoRa modulation parameters.
 
lora_packet_params packet_params () const noexcept
 Returns the configured LoRa packet framing parameters.
 
std::chrono::microseconds time_on_air (size_t payload_length) const noexcept
 Computes the time-on-air of a packet under the configured link parameters.
 
std::optional< rx_duty_cyclerx_duty_cycle_for (uint16_t min_symbols=8) const noexcept
 Computes duty-cycle receive windows for the configured link parameters.
 
void standby ()
 Puts the radio in standby mode.
 
void sleep ()
 Puts the radio in its lowest-power sleep mode.
 
void start_listening ()
 Starts continuous-receive mode.
 
void start_listening (std::chrono::microseconds rx_period, std::chrono::microseconds sleep_period)
 Starts duty-cycled (periodic) receive for low-power listening.
 
void start_listening (rx_duty_cycle cycle)
 Starts duty-cycled (periodic) receive from precomputed windows.
 
void start_listening (const std::optional< rx_duty_cycle > &cycle)
 Starts duty-cycled receive, falling back to continuous receive.
 
idfxx::future< cad_infostart_channel_scan ()
 Starts a one-shot channel-activity scan and returns a future.
 
cad_info scan_channel ()
 Scans the channel for LoRa activity, blocking until the result is known.
 
bool channel_busy ()
 Returns whether LoRa activity is currently detected on the channel.
 
result< void > try_standby ()
 Puts the radio in standby mode.
 
result< void > try_sleep ()
 Puts the radio in its lowest-power sleep mode.
 
result< void > try_start_listening ()
 Starts continuous-receive mode.
 
result< void > try_start_listening (std::chrono::microseconds rx_period, std::chrono::microseconds sleep_period)
 Starts duty-cycled (periodic) receive for low-power listening.
 
result< void > try_start_listening (rx_duty_cycle cycle)
 Starts duty-cycled (periodic) receive from precomputed windows.
 
result< void > try_start_listening (const std::optional< rx_duty_cycle > &cycle)
 Starts duty-cycled receive, falling back to continuous receive.
 
result< idfxx::future< cad_info > > try_start_channel_scan ()
 Starts a one-shot channel-activity scan and returns a future.
 
result< cad_infotry_scan_channel ()
 Scans the channel for LoRa activity, blocking until the result is known.
 
result< bool > try_channel_busy ()
 Returns whether LoRa activity is currently detected on the channel.
 
void configure (const lora_link &link)
 Applies a complete link configuration.
 
void set_frequency (freq::hertz hz)
 Sets the RF carrier frequency.
 
void set_output_power (electro::dbm power, ramp_time ramp=ramp_time::us_200)
 Sets the transmit output power.
 
void set_modulation (lora_modulation mod)
 Configures the LoRa modulation parameters.
 
void set_packet_params (lora_packet_params params)
 Configures the LoRa packet framing.
 
void set_sync_word (lora_network network)
 Selects the LoRa network by setting the sync word.
 
result< void > try_configure (const lora_link &link)
 Applies a complete link configuration.
 
result< void > try_set_frequency (freq::hertz hz)
 Sets the RF carrier frequency.
 
result< void > try_set_output_power (electro::dbm power, ramp_time ramp=ramp_time::us_200)
 Sets the transmit output power.
 
result< void > try_set_modulation (lora_modulation mod)
 Configures the LoRa modulation parameters.
 
result< void > try_set_packet_params (lora_packet_params params)
 Configures the LoRa packet framing.
 
result< void > try_set_sync_word (lora_network network)
 Selects the LoRa network by setting the sync word.
 
void transmit (std::span< const uint8_t > data)
 Transmits a packet and blocks until completion, sizing the timeout automatically.
 
template<typename Rep , typename Period >
void transmit (std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
 Transmits a packet and blocks until completion.
 
template<typename Rep , typename Period >
rx_info receive (std::span< uint8_t > buffer, const std::chrono::duration< Rep, Period > &timeout)
 Receives a single packet, blocking until one arrives or the timeout expires.
 
result< void > try_transmit (std::span< const uint8_t > data)
 Transmits a packet and blocks until completion, sizing the timeout automatically.
 
template<typename Rep , typename Period >
result< void > try_transmit (std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
 Transmits a packet and blocks until completion.
 
template<typename Rep , typename Period >
result< rx_infotry_receive (std::span< uint8_t > buffer, const std::chrono::duration< Rep, Period > &timeout)
 Receives a single packet, blocking until one arrives or the timeout expires.
 
idfxx::future< void > start_transmit (std::span< const uint8_t > data)
 Starts a transmit and returns a future tracking its completion.
 
idfxx::future< rx_infostart_receive (std::span< uint8_t > buffer)
 Starts a single-shot receive into the caller's buffer.
 
rx_info read_received (std::span< uint8_t > buffer)
 Reads the most recently received packet into the caller's buffer.
 
result< idfxx::future< void > > try_start_transmit (std::span< const uint8_t > data)
 Starts a transmit and returns a future tracking its completion.
 
result< idfxx::future< rx_info > > try_start_receive (std::span< uint8_t > buffer)
 Starts a single-shot receive into the caller's buffer.
 
result< rx_infotry_read_received (std::span< uint8_t > buffer)
 Reads the most recently received packet into the caller's buffer.
 
packet_status last_packet_status ()
 Returns detailed status for the most recent packet.
 
electro::centi_dbm current_rssi ()
 Returns the instantaneous RSSI on the configured channel.
 
result< packet_statustry_last_packet_status ()
 Returns detailed status for the most recent packet.
 
result< electro::centi_dbm > try_current_rssi ()
 Returns the instantaneous RSSI on the configured channel.
 

Static Public Member Functions

static result< sx126xmake (spi::master_bus &bus, config config)
 Creates a new SX126x driver on the given SPI bus.
 

Additional Inherited Members

- Static Public Attributes inherited from idfxx::radio::lora_transceiver
static constexpr size_t max_payload_length = 255
 Maximum LoRa payload length in bytes.
 
static constexpr std::chrono::milliseconds transmit_timeout_margin {250}
 Margin added to the packet's time-on-air when the blocking transmit overload without a timeout sizes its own wait: covers command staging, PA ramp-up, and scheduling latency on top of the pure air-time.
 
static constexpr std::chrono::milliseconds scan_guard_window {1000}
 Guard window for the blocking scan_channel.
 
- Protected Member Functions inherited from idfxx::radio::lora_transceiver
 lora_transceiver ()=default
 
 lora_transceiver (lora_transceiver &&) noexcept=default
 
lora_transceiveroperator= (lora_transceiver &&) noexcept=default
 

Detailed Description

Concrete LoRa radio driver for the Semtech SX126x family.

Covers the SX1261 (sub-GHz, max +15 dBm), SX1262 (sub-GHz, max +22 dBm), and SX1268 (sub-GHz, max +22 dBm, PA tuned for 410–810 MHz). The variant is selected at construction via config::variant; the driver then picks the correct PA-config table and validates output-power range.

Move-only and non-copyable, like the rest of idfxx. The destructor tears down the worker task, removes the DIO1 ISR, and puts the chip in sleep mode.

Definition at line 79 of file sx126x.hpp.

Member Typedef Documentation

◆ irq_flag

IRQ-register bitfield enumeration. See sx126x_irq_flag.

Definition at line 82 of file sx126x.hpp.

Member Enumeration Documentation

◆ cad_symbols

enum class idfxx::radio::sx126x::cad_symbols : uint8_t
strong

Number of symbols a CAD (channel activity detection) operates on.

The chip supports only these five values (DS_SX1261-2 §13.4.7, table 13-72). The enumerator value is the cadSymbolNum register byte.

Enumerator
sym_1 

CAD over 1 symbol (CAD_ON_1_SYMB).

sym_2 

CAD over 2 symbols (CAD_ON_2_SYMB).

sym_4 

CAD over 4 symbols (CAD_ON_4_SYMB).

sym_8 

CAD over 8 symbols (CAD_ON_8_SYMB).

sym_16 

CAD over 16 symbols (CAD_ON_16_SYMB).

Definition at line 158 of file sx126x.hpp.

◆ chip_variant

enum class idfxx::radio::sx126x::chip_variant : uint8_t
strong

SX126x family chip variant.

Determines the PA configuration the driver applies and the output-power range it accepts from set_output_power.

Enumerator
sx1261 

Sub-GHz, low-power PA, max +15 dBm.

sx1262 

Sub-GHz, high-power PA, max +22 dBm.

sx1268 

Sub-GHz, high-power PA tuned for 410–810 MHz, max +22 dBm.

Definition at line 91 of file sx126x.hpp.

◆ regulator

enum class idfxx::radio::sx126x::regulator : uint8_t
strong

Voltage regulator selection.

Enumerator
ldo 

LDO regulator (universally safe).

dc_dc 

DC-DC + LDO (requires board support).

Definition at line 101 of file sx126x.hpp.

◆ sleep_mode

enum class idfxx::radio::sx126x::sleep_mode : uint8_t
strong

Sleep-mode configuration retention.

The chip-agnostic lora_transceiver::sleep performs a warm sleep; the SX126x-specific sleep(sleep_mode) overload can request a cold sleep, which loses all configuration and requires the driver's defaults and the caller's settings to be reapplied on wake.

Enumerator
warm 

Retain register configuration for fast wake-up.

cold 

Lowest-power sleep; all configuration is lost.

Definition at line 128 of file sx126x.hpp.

◆ standby_clock

enum class idfxx::radio::sx126x::standby_clock : uint8_t
strong

Clock source kept running in standby mode.

The chip-agnostic lora_transceiver::standby uses the low-power RC oscillator; the SX126x-specific standby(standby_clock) overload selects the crystal oscillator for a faster transition into transmit or receive.

Enumerator
rc 

13 MHz RC oscillator (lowest standby current).

xosc 

Crystal oscillator (faster TX/RX transitions, higher current).

Definition at line 114 of file sx126x.hpp.

Constructor & Destructor Documentation

◆ sx126x() [1/3]

idfxx::radio::sx126x::sx126x ( spi::master_bus bus,
config  config 
)
explicit

Constructs a new SX126x driver on the given SPI bus.

Does not take ownership of bus. The caller must ensure the bus outlives this driver.

Parameters
busParent SPI master bus.
configDriver configuration.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

◆ ~sx126x()

idfxx::radio::sx126x::~sx126x ( )
override

◆ sx126x() [2/3]

idfxx::radio::sx126x::sx126x ( const sx126x )
delete

◆ sx126x() [3/3]

idfxx::radio::sx126x::sx126x ( sx126x &&  other)
noexcept

Member Function Documentation

◆ adopt_pending()

std::optional< rx_info > idfxx::radio::sx126x::adopt_pending ( )
inline

Drains an IRQ the chip latched while no driver was running.

Intended for use immediately after a warm start (see config::warm_start): a packet the chip received while the host slept leaves rx_done latched and DIO1 high, but the driver's interrupt handler never saw the edge. This reads and clears the pending IRQ status and, for a latched rx_done, reads the packet out of the chip into the receive cache, where lora_transceiver::read_received picks it up.

Returns
The received packet's info if one was adopted, or std::nullopt if no packet was pending.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure (including a corrupt pending packet, reported as idfxx::errc::invalid_crc).
// After waking from deep sleep with the chip left duty-cycle listening:
idfxx::radio::sx126x radio(bus, {..., .nreset = idfxx::gpio::nc(), .warm_start = true});
if (auto pkt = radio.adopt_pending()) {
std::array<uint8_t, 255> buf;
auto info = radio.read_received(buf);
// handle buf[0..info.length)
}
static constexpr gpio nc()
Returns a GPIO representing "not connected".
Definition gpio.hpp:255
Concrete LoRa radio driver for the Semtech SX126x family.
Definition sx126x.hpp:79

Definition at line 398 of file sx126x.hpp.

References try_adopt_pending(), and idfxx::unwrap().

◆ clear_irq_status()

void idfxx::radio::sx126x::clear_irq_status ( flags< irq_flag mask)
inline

Clears the specified IRQ bits.

Parameters
maskBits to clear.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 414 of file sx126x.hpp.

References try_clear_irq_status(), and idfxx::unwrap().

◆ irq_status()

flags< irq_flag > idfxx::radio::sx126x::irq_status ( )
inline

Returns the current IRQ-register status.

Returns
Bitfield of pending IRQs.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 406 of file sx126x.hpp.

References try_irq_status(), and idfxx::unwrap().

◆ make()

static result< sx126x > idfxx::radio::sx126x::make ( spi::master_bus bus,
config  config 
)
static

Creates a new SX126x driver on the given SPI bus.

Does not take ownership of bus. The caller must ensure the bus outlives this driver.

Parameters
busParent SPI master bus.
configDriver configuration.
Returns
The new driver, or an error.

◆ operator=() [1/2]

sx126x & idfxx::radio::sx126x::operator= ( const sx126x )
delete

◆ operator=() [2/2]

sx126x & idfxx::radio::sx126x::operator= ( sx126x &&  other)
noexcept

◆ read_buffer()

void idfxx::radio::sx126x::read_buffer ( uint8_t  offset,
std::span< uint8_t >  data 
)
inline

Reads the chip's data buffer at the specified offset.

Parameters
offsetByte offset within the 256-byte chip buffer.
dataBuffer to receive into.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 519 of file sx126x.hpp.

References try_read_buffer(), and idfxx::unwrap().

◆ read_command()

void idfxx::radio::sx126x::read_command ( uint8_t  opcode,
std::span< uint8_t >  response 
)
inline

Sends a command opcode and reads the response bytes.

Parameters
opcodeCommand opcode.
responseBuffer to receive response bytes into.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 483 of file sx126x.hpp.

References try_read_command(), and idfxx::unwrap().

◆ read_register()

void idfxx::radio::sx126x::read_register ( uint16_t  addr,
std::span< uint8_t >  data 
)
inline

Reads one or more chip registers.

Parameters
addr16-bit register address.
dataBuffer to receive into.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 501 of file sx126x.hpp.

References try_read_register(), and idfxx::unwrap().

◆ set_cad_params()

void idfxx::radio::sx126x::set_cad_params ( cad_params  params)
inline

Sets CAD detection parameters.

Tunes the chip's CAD detection thresholds. The chip-agnostic lora_transceiver::try_start_channel_scan uses driver defaults.

Parameters
paramsCAD detection parameters.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 370 of file sx126x.hpp.

References try_set_cad_params(), and idfxx::unwrap().

◆ set_sync_word() [1/2]

void idfxx::radio::lora_transceiver::set_sync_word ( lora_network  network)
inline

Selects the LoRa network by setting the sync word.

Senders and receivers must select the same network to hear each other. Each driver maps the selection to its chip's native sync-word encoding; chip-specific raw values remain available through driver-specific overloads (e.g. sx126x::set_sync_word(uint16_t)).

Parameters
networkNetwork whose sync word to use.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 503 of file lora_transceiver.hpp.

◆ set_sync_word() [2/2]

void idfxx::radio::sx126x::set_sync_word ( uint16_t  sync_word)
inline

Sets a raw 16-bit LoRa sync word.

For interoperating with networks that use a non-standard sync word. The inherited lora_transceiver::set_sync_word overload selects the standard public/private network values.

Parameters
sync_wordRaw sync-word register value (MSB first).
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 358 of file sx126x.hpp.

References try_set_sync_word(), and idfxx::unwrap().

◆ sleep() [1/2]

void idfxx::radio::lora_transceiver::sleep ( )
inline

Puts the radio in its lowest-power sleep mode.

Configuration is retained where the chip supports it, so the next operation wakes the radio without a full reconfiguration.

Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 177 of file lora_transceiver.hpp.

◆ sleep() [2/2]

void idfxx::radio::sx126x::sleep ( sleep_mode  mode)
inline

Puts the radio in sleep mode with the selected retention.

The inherited lora_transceiver::sleep performs a warm sleep (configuration retained). Select sleep_mode::cold for the lowest-power sleep, in which all configuration is lost and must be reapplied on wake.

Parameters
modeConfiguration-retention mode.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 320 of file sx126x.hpp.

References try_sleep(), and idfxx::unwrap().

◆ spi()

spi::master_device & idfxx::radio::sx126x::spi ( )
noexcept

Returns the underlying SPI device for advanced/diagnostic use.

Precondition
The driver has not been moved from.

◆ standby() [1/2]

void idfxx::radio::lora_transceiver::standby ( )
inline

Puts the radio in standby mode.

Standby stops any in-progress receive or channel scan and parks the radio with its configuration retained, ready for the next operation.

Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 166 of file lora_transceiver.hpp.

◆ standby() [2/2]

void idfxx::radio::sx126x::standby ( standby_clock  clock)
inline

Puts the radio in standby mode with the selected clock source.

The inherited lora_transceiver::standby uses the low-power RC oscillator; select standby_clock::xosc to keep the crystal oscillator running for faster transitions into transmit or receive.

Parameters
clockClock source to keep running in standby.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 307 of file sx126x.hpp.

References try_standby(), and idfxx::unwrap().

◆ try_adopt_pending()

result< std::optional< rx_info > > idfxx::radio::sx126x::try_adopt_pending ( )

Drains an IRQ the chip latched while no driver was running.

Result variant of adopt_pending; see there for the warm-start recovery flow this supports.

Returns
The received packet's info if one was adopted, std::nullopt if no packet was pending, or an error.
Return values
idfxx::errc::invalid_crcA packet was pending but failed the chip's CRC check; the IRQ has been cleared.

Referenced by adopt_pending().

◆ try_clear_irq_status()

result< void > idfxx::radio::sx126x::try_clear_irq_status ( flags< irq_flag mask)

Clears the specified IRQ bits.

Parameters
maskBits to clear.
Returns
Success, or an error.

Referenced by clear_irq_status().

◆ try_irq_status()

result< flags< irq_flag > > idfxx::radio::sx126x::try_irq_status ( )

Returns the current IRQ-register status.

Returns
Bitfield of pending IRQs, or an error.

Referenced by irq_status().

◆ try_read_buffer()

result< void > idfxx::radio::sx126x::try_read_buffer ( uint8_t  offset,
std::span< uint8_t >  data 
)

Result variant of read_buffer.

Referenced by read_buffer().

◆ try_read_command()

result< void > idfxx::radio::sx126x::try_read_command ( uint8_t  opcode,
std::span< uint8_t >  response 
)

Result variant of read_command.

Referenced by read_command().

◆ try_read_register()

result< void > idfxx::radio::sx126x::try_read_register ( uint16_t  addr,
std::span< uint8_t >  data 
)

Result variant of read_register.

Referenced by read_register().

◆ try_set_cad_params()

result< void > idfxx::radio::sx126x::try_set_cad_params ( cad_params  params)

Sets CAD detection parameters.

Parameters
paramsCAD detection parameters.
Returns
Success, or an error.

Referenced by set_cad_params().

◆ try_set_sync_word() [1/2]

result< void > idfxx::radio::lora_transceiver::try_set_sync_word ( lora_network  network)
inline

Selects the LoRa network by setting the sync word.

Senders and receivers must select the same network to hear each other. Each driver maps the selection to its chip's native sync-word encoding.

Parameters
networkNetwork whose sync word to use.
Returns
Success, or an error.

Definition at line 591 of file lora_transceiver.hpp.

◆ try_set_sync_word() [2/2]

result< void > idfxx::radio::sx126x::try_set_sync_word ( uint16_t  sync_word)

Sets a raw 16-bit LoRa sync word.

For interoperating with networks that use a non-standard sync word. The inherited lora_transceiver::try_set_sync_word overload selects the standard public/private network values.

Parameters
sync_wordRaw sync-word register value (MSB first).
Returns
Success, or an error.

Referenced by set_sync_word().

◆ try_sleep() [1/2]

result< void > idfxx::radio::lora_transceiver::try_sleep ( )
inline

Puts the radio in its lowest-power sleep mode.

Configuration is retained where the chip supports it, so the next operation wakes the radio without a full reconfiguration.

Returns
Success, or an error.

Definition at line 315 of file lora_transceiver.hpp.

Referenced by sleep().

◆ try_sleep() [2/2]

result< void > idfxx::radio::sx126x::try_sleep ( sleep_mode  mode)

Puts the radio in sleep mode with the selected retention.

Parameters
modeConfiguration-retention mode.
Returns
Success, or an error.

◆ try_standby() [1/2]

result< void > idfxx::radio::lora_transceiver::try_standby ( )
inline

Puts the radio in standby mode.

Standby stops any in-progress receive or channel scan and parks the radio with its configuration retained, ready for the next operation.

Returns
Success, or an error.

Definition at line 305 of file lora_transceiver.hpp.

Referenced by standby().

◆ try_standby() [2/2]

result< void > idfxx::radio::sx126x::try_standby ( standby_clock  clock)

Puts the radio in standby mode with the selected clock source.

Parameters
clockClock source to keep running in standby.
Returns
Success, or an error.

◆ try_write_buffer()

result< void > idfxx::radio::sx126x::try_write_buffer ( uint8_t  offset,
std::span< const uint8_t >  data 
)

Result variant of write_buffer.

Referenced by write_buffer().

◆ try_write_command()

result< void > idfxx::radio::sx126x::try_write_command ( uint8_t  opcode,
std::span< const uint8_t >  params 
)

Result variant of write_command.

Referenced by write_command().

◆ try_write_register()

result< void > idfxx::radio::sx126x::try_write_register ( uint16_t  addr,
std::span< const uint8_t >  data 
)

Result variant of write_register.

Referenced by write_register().

◆ variant()

chip_variant idfxx::radio::sx126x::variant ( ) const
noexcept

Returns the configured chip variant.

◆ write_buffer()

void idfxx::radio::sx126x::write_buffer ( uint8_t  offset,
std::span< const uint8_t >  data 
)
inline

Writes the chip's data buffer at the specified offset.

Parameters
offsetByte offset within the 256-byte chip buffer.
dataBytes to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 510 of file sx126x.hpp.

References try_write_buffer(), and idfxx::unwrap().

◆ write_command()

void idfxx::radio::sx126x::write_command ( uint8_t  opcode,
std::span< const uint8_t >  params 
)
inline

Sends a command opcode with parameter bytes.

Parameters
opcodeCommand opcode.
paramsParameter bytes to send after the opcode.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 474 of file sx126x.hpp.

References try_write_command(), and idfxx::unwrap().

◆ write_register()

void idfxx::radio::sx126x::write_register ( uint16_t  addr,
std::span< const uint8_t >  data 
)
inline

Writes one or more chip registers.

Parameters
addr16-bit register address.
dataBytes to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 492 of file sx126x.hpp.

References try_write_register(), and idfxx::unwrap().


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