|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Abstract base class for LoRa radio transceivers. More...
Public Member Functions | |
| virtual | ~lora_transceiver ()=default |
| lora_transceiver (const lora_transceiver &)=delete | |
| lora_transceiver & | operator= (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_cycle > | rx_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_info > | start_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_info > | try_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_info > | try_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_info > | start_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_info > | try_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_status > | try_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 Attributes | |
| 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 | |
| lora_transceiver ()=default | |
| lora_transceiver (lora_transceiver &&) noexcept=default | |
| lora_transceiver & | operator= (lora_transceiver &&) noexcept=default |
| virtual chip_mode | do_current_mode () const noexcept=0 |
| Hook for current_mode. | |
| virtual result< void > | do_standby ()=0 |
| Hook for try_standby. | |
| virtual result< void > | do_sleep ()=0 |
| Hook for try_sleep. | |
| virtual result< void > | do_start_listening ()=0 |
| Hook for try_start_listening() (continuous receive). | |
| virtual result< void > | do_start_listening (std::chrono::microseconds rx_period, std::chrono::microseconds sleep_period) |
| Hook for try_start_listening(std::chrono::microseconds, std::chrono::microseconds) (duty-cycled receive). | |
| virtual result< idfxx::future< cad_info > > | do_start_channel_scan ()=0 |
| Hook for try_start_channel_scan. | |
| virtual result< void > | do_set_frequency (freq::hertz hz)=0 |
| Hook for try_set_frequency. | |
| virtual result< void > | do_set_output_power (electro::dbm power, ramp_time ramp)=0 |
| Hook for try_set_output_power. | |
| virtual result< void > | do_set_modulation (lora_modulation mod)=0 |
| Hook for try_set_modulation. | |
| virtual result< void > | do_set_packet_params (lora_packet_params params)=0 |
| Hook for try_set_packet_params. | |
| virtual result< void > | do_set_sync_word (lora_network network)=0 |
| Hook for try_set_sync_word. | |
| virtual result< idfxx::future< void > > | do_start_transmit (std::span< const uint8_t > data)=0 |
| Hook for try_start_transmit. | |
| virtual result< idfxx::future< rx_info > > | do_start_receive (std::span< uint8_t > buffer)=0 |
| Hook for try_start_receive(std::span<uint8_t>) (single-shot receive). | |
| virtual result< rx_info > | do_read_received (std::span< uint8_t > buffer)=0 |
| Hook for try_read_received. | |
| virtual result< packet_status > | do_last_packet_status ()=0 |
| Hook for try_last_packet_status. | |
| virtual result< electro::centi_dbm > | do_current_rssi ()=0 |
| Hook for try_current_rssi. | |
| virtual std::chrono::microseconds | do_rx_duty_cycle_min_sleep () const noexcept |
| Hook for rx_duty_cycle_for: the shortest sleep window worth duty-cycling for on this chip. | |
Abstract base class for LoRa radio transceivers.
The public interface is non-virtual; concrete drivers (e.g. idfxx::radio::sx126x) customize behaviour by overriding the protected do_* hooks, mirroring the standard library's non-virtual-interface pattern (cf. std::pmr::memory_resource).
Three coordinated styles are exposed: blocking calls (transmit/receive/ scan_channel), future-based one-shot operations (start_transmit, single-shot start_receive(buffer), and start_channel_scan, each returning an idfxx::future), and event-loop dispatch for packet streams (continuous and duty-cycled start_listening, surfacing packets via the typed events declared in <idfxx/radio/events>; pair them with read_received). Futures and events coexist: one-shot operations also post their completion event when an event loop is configured.
Definition at line 61 of file lora_transceiver.hpp.
|
virtualdefault |
|
delete |
|
protecteddefault |
|
protecteddefaultnoexcept |
|
inline |
Returns whether LoRa activity is currently detected on the channel.
Convenience over scan_channel for listen-before-talk: scan, then transmit only if the channel is clear.
| std::system_error | on failure, including errc::timeout if the scan does not complete within scan_guard_window. |
Definition at line 294 of file lora_transceiver.hpp.
References try_channel_busy(), and idfxx::unwrap().
|
inline |
Applies a complete link configuration.
Sets the frequency, output power, modulation, packet framing, and network (sync word) in one call — equivalent to calling the individual setters in sequence. Both ends of a link must agree on every field except the output power.
| link | Link configuration; link.frequency is required. |
| std::system_error | on failure, including errc::invalid_arg if link.frequency is unset (zero). |
Definition at line 452 of file lora_transceiver.hpp.
References try_configure(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the radio's current high-level mode.
Definition at line 77 of file lora_transceiver.hpp.
References do_current_mode().
|
inline |
Returns the instantaneous RSSI on the configured channel.
| std::system_error | on failure. |
Definition at line 862 of file lora_transceiver.hpp.
References try_current_rssi(), and idfxx::unwrap().
|
protectedpure virtualnoexcept |
Hook for current_mode.
Referenced by current_mode().
|
protectedpure virtual |
Hook for try_current_rssi.
Referenced by try_current_rssi().
|
protectedpure virtual |
Hook for try_last_packet_status.
Referenced by try_last_packet_status().
|
protectedpure virtual |
Hook for try_read_received.
Referenced by try_read_received().
|
inlineprotectedvirtualnoexcept |
Hook for rx_duty_cycle_for: the shortest sleep window worth duty-cycling for on this chip.
Drivers add any per-wake oscillator start-up cost to the generic default (e.g. the SX126x adds its configured TCXO start-up delay).
Definition at line 967 of file lora_transceiver.hpp.
References idfxx::radio::default_min_rx_sleep.
Referenced by rx_duty_cycle_for().
|
protectedpure virtual |
Hook for try_set_frequency.
Referenced by try_set_frequency().
|
protectedpure virtual |
Hook for try_set_modulation.
Referenced by try_set_modulation().
|
protectedpure virtual |
Hook for try_set_output_power.
Referenced by try_set_output_power().
|
protectedpure virtual |
Hook for try_set_packet_params.
Referenced by try_set_packet_params().
|
protectedpure virtual |
Hook for try_set_sync_word.
Referenced by try_set_sync_word().
|
protectedpure virtual |
Hook for try_sleep.
Referenced by try_sleep().
|
protectedpure virtual |
Hook for try_standby.
Referenced by try_standby().
|
protectedpure virtual |
Hook for try_start_channel_scan.
The returned future must complete with the scan result, or with errc::not_finished if the operation is cancelled (standby, sleep, or driver teardown).
Referenced by try_start_channel_scan().
|
protectedpure virtual |
Hook for try_start_listening() (continuous receive).
Referenced by try_start_listening(), and try_start_listening().
|
inlineprotectedvirtual |
Hook for try_start_listening(std::chrono::microseconds, std::chrono::microseconds) (duty-cycled receive).
Both durations are positive. Hardware duty-cycled listening is optional: drivers whose chip cannot listen autonomously keep this default, which reports errc::not_supported.
Definition at line 920 of file lora_transceiver.hpp.
References idfxx::error(), and idfxx::not_supported.
|
protectedpure virtual |
Hook for try_start_receive(std::span<uint8_t>) (single-shot receive).
The returned future must complete with the received packet's info (errc::invalid_crc on CRC failure), or with errc::not_finished if the operation is cancelled (standby, sleep, or driver teardown); the buffer must never be written after the future completes.
Referenced by try_start_receive().
|
protectedpure virtual |
Hook for try_start_transmit.
The payload is non-empty and at most max_payload_length bytes, and is staged before the hook returns (the caller's buffer need not outlive the call). The returned future must complete when the packet has been sent, or with errc::not_finished if the operation is cancelled (standby, sleep, or driver teardown).
Referenced by try_start_transmit().
|
inline |
Returns detailed status for the most recent packet.
| std::system_error | on failure. |
Definition at line 854 of file lora_transceiver.hpp.
References try_last_packet_status(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the configured LoRa modulation parameters.
Reflects the most recent successful try_set_modulation / set_modulation, or the defaults (lora_modulation{}) before any call. Used by time_on_air and rx_duty_cycle_for so callers need not keep their own copy of the link configuration.
Definition at line 89 of file lora_transceiver.hpp.
|
delete |
|
protecteddefaultnoexcept |
|
inlinenoexcept |
Returns the configured LoRa packet framing parameters.
Reflects the most recent successful try_set_packet_params / set_packet_params, or the defaults (lora_packet_params{}) before any call.
Definition at line 100 of file lora_transceiver.hpp.
|
inline |
Reads the most recently received packet into the caller's buffer.
Typically called from a rx_done event handler. The radio's internal cache holds only the most recent packet; calling this after a second rx_done returns that newer packet. Always pair the copied bytes with the rx_info this call returns — the rx_done event's payload may describe an older packet than the cache.
| buffer | Buffer to copy the payload into. |
| std::system_error | on failure. |
Definition at line 774 of file lora_transceiver.hpp.
References try_read_received(), and idfxx::unwrap().
|
inline |
Receives a single packet, blocking until one arrives or the timeout expires.
| buffer | Buffer to receive into. |
| timeout | Maximum time to wait for a packet. |
| std::system_error | on failure, including errc::timeout and errc::invalid_crc. |
Definition at line 632 of file lora_transceiver.hpp.
References idfxx::radio::timeout, try_receive(), and idfxx::unwrap().
|
inlinenoexcept |
Computes duty-cycle receive windows for the configured link parameters.
Equivalent to the free function idfxx::radio::rx_duty_cycle_for called with modulation, the configured preamble length (senders on the link are assumed to use the same packet_params), and the driver's minimum worthwhile sleep window — which includes any oscillator start-up cost the chip pays on each wake (e.g. the SX126x TCXO delay).
Returns std::nullopt when duty-cycling cannot reliably catch packets; passing the result straight to start_listening then falls back to continuous receive.
| min_symbols | Minimum preamble symbols the radio must observe to detect a packet; must be at least 1. |
std::nullopt if duty-cycling cannot reliably catch packets.Definition at line 146 of file lora_transceiver.hpp.
References do_rx_duty_cycle_min_sleep(), idfxx::radio::lora_packet_params::preamble_length, and idfxx::radio::rx_duty_cycle_for().
|
inline |
Scans the channel for LoRa activity, blocking until the result is known.
Runs one channel-activity-detection operation with driver-default detection parameters and blocks until it completes, returning whether activity was detected. Intended for listen-before-talk: scan, then transmit only if the channel is clear.
| std::system_error | on failure, including errc::timeout if the scan does not complete within scan_guard_window. |
Definition at line 275 of file lora_transceiver.hpp.
References try_scan_channel(), and idfxx::unwrap().
|
inline |
Sets the RF carrier frequency.
| hz | Carrier frequency. |
| std::system_error | on failure. |
Definition at line 460 of file lora_transceiver.hpp.
References try_set_frequency(), and idfxx::unwrap().
|
inline |
Configures the LoRa modulation parameters.
| mod | Spreading factor, bandwidth, coding rate. |
| std::system_error | on failure. |
Definition at line 481 of file lora_transceiver.hpp.
References try_set_modulation(), and idfxx::unwrap().
|
inline |
Sets the transmit output power.
| power | Output power. Valid range depends on the chip variant; drivers return errc::invalid_arg for values outside their supported range. |
| ramp | Output-power ramp-up time (driver maps to nearest supported value). |
| std::system_error | on failure. |
Definition at line 471 of file lora_transceiver.hpp.
References try_set_output_power(), and idfxx::unwrap().
|
inline |
Configures the LoRa packet framing.
| params | Preamble, header type, CRC, IQ inversion, etc. |
| std::system_error | on failure. |
Definition at line 489 of file lora_transceiver.hpp.
References try_set_packet_params(), and idfxx::unwrap().
|
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)).
| network | Network whose sync word to use. |
| std::system_error | on failure. |
Definition at line 503 of file lora_transceiver.hpp.
References try_set_sync_word(), and idfxx::unwrap().
|
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.
| std::system_error | on failure. |
Definition at line 177 of file lora_transceiver.hpp.
References try_sleep(), and idfxx::unwrap().
|
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.
| std::system_error | on failure. |
Definition at line 166 of file lora_transceiver.hpp.
References try_standby(), and idfxx::unwrap().
|
inline |
Starts a one-shot channel-activity scan and returns a future.
The returned future completes with the scan result (cad_info); when an event loop is configured the result is also posted as a cad_done event. Uses driver-default detection parameters; drivers may expose a chip-specific method to tune those (e.g. sx126x::set_cad_params). For a blocking scan, use scan_channel instead.
Dropping the future without waiting is safe: the scan continues and the result remains observable through the cad_done event.
| std::system_error | on failure. |
Definition at line 260 of file lora_transceiver.hpp.
References try_start_channel_scan(), and idfxx::unwrap().
|
inline |
Starts continuous-receive mode.
The radio runs continuously, posting rx_done (and on errors, crc_error) events as packets arrive. Use read_received to extract the payload from inside the event handler. Call standby to stop receiving.
| std::system_error | on failure. |
Definition at line 190 of file lora_transceiver.hpp.
References try_start_listening(), and idfxx::unwrap().
|
inline |
Starts duty-cycled receive, falling back to continuous receive.
Accepts the result of rx_duty_cycle_for directly: starts duty-cycled receive when cycle holds windows, and continuous receive when it is std::nullopt (duty-cycling could not reliably catch packets for the link's modulation and preamble length).
| cycle | Listen/sleep windows, or std::nullopt for continuous receive. |
| std::system_error | on failure. |
Definition at line 241 of file lora_transceiver.hpp.
References try_start_listening(), and idfxx::unwrap().
|
inline |
Starts duty-cycled (periodic) receive from precomputed windows.
Equivalent to start_listening(cycle.rx_period, cycle.sleep_period). Compute the windows with rx_duty_cycle_for (<idfxx/radio/duty_cycle>) or build them directly.
| cycle | Listen/sleep windows for each cycle. |
| std::system_error | on failure, including errc::invalid_arg for a non-positive listen or sleep window. |
Definition at line 223 of file lora_transceiver.hpp.
References try_start_listening(), and idfxx::unwrap().
|
inline |
Starts duty-cycled (periodic) receive for low-power listening.
The radio alternates between listening for rx_period and sleeping for sleep_period, repeating until a packet arrives or the mode is changed. As with the continuous overload, packets surface through rx_done (and crc_error) events; use read_received to extract the payload.
| rx_period | Time to listen in each cycle. |
| sleep_period | Time to sleep in each cycle. |
| std::system_error | on failure, including errc::invalid_arg for a non-positive rx_period or sleep_period. |
Definition at line 207 of file lora_transceiver.hpp.
References try_start_listening(), and idfxx::unwrap().
|
inline |
Starts a single-shot receive into the caller's buffer.
Receives exactly one packet: the radio listens until a packet arrives, copies the payload into buffer (clamped to its size), completes the returned future with the packet's rx_info, and returns to standby. For a packet stream, use the continuous or duty-cycled start_listening overloads instead.
buffer must remain valid until the future completes or the operation is cancelled by a mode change (standby or sleep).
Dropping the future without waiting is safe: the receive continues and the packet remains observable through the rx_done event and read_received.
| buffer | Buffer to receive the payload into. |
| std::system_error | on failure. |
Definition at line 756 of file lora_transceiver.hpp.
References try_start_receive(), and idfxx::unwrap().
|
inline |
Starts a transmit and returns a future tracking its completion.
The companion to the blocking transmit: the call returns as soon as the packet is staged and transmission has started, so the caller's task is free to do other work and can await the returned future when it needs the result. When an event loop is configured, completion is also posted as a tx_done event.
Only one data-path operation may be in flight at a time; calling this (or any other transmit/receive/scan) again before completion returns errc::invalid_state. There is no built-in transmit timeout — wait on the future with a try_wait_for() sized via time_on_air and call standby to cancel the operation if it never completes.
Dropping the future without waiting is safe: the transmission continues and completion remains observable through the tx_done event.
| data | Payload to transmit (1–255 bytes). The payload is staged on-chip before this call returns, so the buffer need not outlive the call. |
| std::system_error | on failure. |
Definition at line 731 of file lora_transceiver.hpp.
References try_start_transmit(), and idfxx::unwrap().
|
inlinenoexcept |
Computes the time-on-air of a packet under the configured link parameters.
Equivalent to the free function idfxx::radio::time_on_air called with modulation and packet_params, so it always agrees with what the radio was actually configured with.
| payload_length | Number of payload bytes the packet carries. |
Definition at line 120 of file lora_transceiver.hpp.
References idfxx::radio::time_on_air().
Referenced by try_transmit().
|
inline |
Transmits a packet and blocks until completion, sizing the timeout automatically.
Waits at most the packet's time_on_air — computed from the configured link parameters — plus transmit_timeout_margin.
| data | Payload to transmit (1–255 bytes). |
| std::system_error | on failure or timeout. |
Definition at line 608 of file lora_transceiver.hpp.
References try_transmit(), and idfxx::unwrap().
|
inline |
Transmits a packet and blocks until completion.
| data | Payload to transmit (1–255 bytes). |
| timeout | Maximum time to wait for transmit completion. |
| std::system_error | on failure or timeout. |
Definition at line 618 of file lora_transceiver.hpp.
References idfxx::radio::timeout, try_transmit(), and idfxx::unwrap().
|
inline |
Returns whether LoRa activity is currently detected on the channel.
Convenience over try_scan_channel for listen-before-talk: scan, then transmit only if the channel is clear.
| timeout | The scan did not complete within scan_guard_window. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 418 of file lora_transceiver.hpp.
References idfxx::error(), and try_scan_channel().
Referenced by channel_busy().
Applies a complete link configuration.
Sets the frequency, output power, modulation, packet framing, and network (sync word) in one call — equivalent to calling the individual setters in sequence, stopping at the first failure. Both ends of a link must agree on every field except the output power.
| link | Link configuration; link.frequency is required. |
| invalid_arg | link.frequency is unset (zero), or a field is outside the driver's supported range. |
Definition at line 519 of file lora_transceiver.hpp.
References idfxx::error(), idfxx::radio::lora_link::frequency, idfxx::invalid_arg, idfxx::radio::lora_link::modulation, idfxx::radio::lora_link::network, idfxx::radio::lora_link::output_power, idfxx::radio::lora_link::packet_params, idfxx::radio::lora_link::ramp, try_set_frequency(), try_set_modulation(), try_set_output_power(), try_set_packet_params(), and try_set_sync_word().
Referenced by configure().
|
inline |
Returns the instantaneous RSSI on the configured channel.
Definition at line 875 of file lora_transceiver.hpp.
References do_current_rssi().
Referenced by current_rssi().
|
inline |
Returns detailed status for the most recent packet.
Definition at line 869 of file lora_transceiver.hpp.
References do_last_packet_status().
Referenced by last_packet_status().
|
inline |
Reads the most recently received packet into the caller's buffer.
Always pair the copied bytes with the rx_info this call returns — the rx_done event's payload may describe an older packet than the cache.
| buffer | Buffer to copy the payload into. |
| not_found | No packet has been received yet. |
Definition at line 841 of file lora_transceiver.hpp.
References do_read_received().
Referenced by read_received().
|
inline |
Receives a single packet, blocking until one arrives or the timeout expires.
Equivalent to try_start_receive(std::span<uint8_t>) followed by a wait on the returned future. If no packet arrives within timeout the radio is returned to standby and errc::timeout is reported.
| buffer | Buffer to receive into. |
| timeout | Maximum time to wait for a packet. |
| timeout | No packet arrived within the timeout. |
| invalid_crc | The received packet failed its CRC check. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 693 of file lora_transceiver.hpp.
References idfxx::error(), idfxx::radio::timeout, and try_start_receive().
Referenced by receive().
Scans the channel for LoRa activity, blocking until the result is known.
Equivalent to try_start_channel_scan followed by a wait on the returned future. If the scan does not complete within scan_guard_window the radio is returned to standby and errc::timeout is reported.
| timeout | The scan did not complete within scan_guard_window. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 400 of file lora_transceiver.hpp.
References idfxx::error(), scan_guard_window, and try_start_channel_scan().
Referenced by scan_channel(), and try_channel_busy().
|
inline |
Sets the RF carrier frequency.
| hz | Carrier frequency. |
Definition at line 543 of file lora_transceiver.hpp.
References do_set_frequency().
Referenced by set_frequency(), and try_configure().
|
inline |
Configures the LoRa modulation parameters.
| mod | Spreading factor, bandwidth, coding rate. |
Definition at line 561 of file lora_transceiver.hpp.
References do_set_modulation().
Referenced by set_modulation(), and try_configure().
|
inline |
Sets the transmit output power.
| power | Output power. |
| ramp | Output-power ramp-up time. |
| invalid_arg | The requested power is outside the chip variant's supported range. |
Definition at line 552 of file lora_transceiver.hpp.
References do_set_output_power().
Referenced by set_output_power(), and try_configure().
|
inline |
Configures the LoRa packet framing.
| params | Preamble, header type, CRC, IQ inversion, etc. |
Definition at line 574 of file lora_transceiver.hpp.
References do_set_packet_params().
Referenced by set_packet_params(), and try_configure().
|
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.
| network | Network whose sync word to use. |
Definition at line 591 of file lora_transceiver.hpp.
References do_set_sync_word().
Referenced by set_sync_word(), and try_configure().
|
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.
Definition at line 315 of file lora_transceiver.hpp.
References do_sleep().
Referenced by sleep().
|
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.
Definition at line 305 of file lora_transceiver.hpp.
References do_standby().
Referenced by standby().
|
inline |
Starts a one-shot channel-activity scan and returns a future.
The returned future completes with the scan result (cad_info); when an event loop is configured the result is also posted as a cad_done event. The future completes with errc::not_finished if the scan is cancelled by a mode change (try_standby or try_sleep).
Dropping the future without waiting is safe: the scan continues and the result remains observable through the cad_done event.
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 386 of file lora_transceiver.hpp.
References do_start_channel_scan().
Referenced by start_channel_scan(), and try_scan_channel().
|
inline |
Starts continuous-receive mode.
Packets surface through rx_done (and crc_error) events; use try_read_received to extract the payload. Call try_standby to stop receiving.
Definition at line 326 of file lora_transceiver.hpp.
References do_start_listening().
Referenced by start_listening(), start_listening(), start_listening(), start_listening(), try_start_listening(), and try_start_listening().
|
inline |
Starts duty-cycled receive, falling back to continuous receive.
Accepts the result of rx_duty_cycle_for directly: starts duty-cycled receive when cycle holds windows, and continuous receive when it is std::nullopt.
| cycle | Listen/sleep windows, or std::nullopt for continuous receive. |
Definition at line 368 of file lora_transceiver.hpp.
References try_start_listening().
|
inline |
Starts duty-cycled (periodic) receive from precomputed windows.
Equivalent to try_start_listening(cycle.rx_period, cycle.sleep_period).
| cycle | Listen/sleep windows for each cycle. |
| invalid_arg | The listen or sleep window is not positive. |
| not_supported | The driver has no hardware duty-cycled listening. |
Definition at line 354 of file lora_transceiver.hpp.
References idfxx::radio::rx_duty_cycle::rx_period, idfxx::radio::rx_duty_cycle::sleep_period, and try_start_listening().
|
inline |
Starts duty-cycled (periodic) receive for low-power listening.
| rx_period | Time to listen in each cycle. |
| sleep_period | Time to sleep in each cycle. |
| invalid_arg | rx_period or sleep_period is not positive. |
| not_supported | The driver has no hardware duty-cycled listening. |
Definition at line 337 of file lora_transceiver.hpp.
References do_start_listening(), idfxx::error(), and idfxx::invalid_arg.
|
inline |
Starts a single-shot receive into the caller's buffer.
Receives exactly one packet: the radio listens until a packet arrives, copies the payload into buffer (clamped to its size), completes the returned future with the packet's rx_info, and returns to standby. The future completes with errc::invalid_crc if the packet failed its CRC check, and with errc::not_finished if the operation is cancelled by a mode change (try_standby or try_sleep).
buffer must remain valid until the future completes or the operation is cancelled.
Dropping the future without waiting is safe: the receive continues and the packet remains observable through the rx_done event and try_read_received.
| buffer | Buffer to receive the payload into. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 826 of file lora_transceiver.hpp.
References do_start_receive().
Referenced by start_receive(), and try_receive().
|
inline |
Starts a transmit and returns a future tracking its completion.
The call returns as soon as the packet is staged and transmission has started; the returned future completes when the packet has been sent (or with errc::not_finished if the operation is cancelled by a mode change). When an event loop is configured, completion is also posted as a tx_done event. Only one data-path operation may be in flight at a time.
Dropping the future without waiting is safe: the transmission continues and completion remains observable through the tx_done event.
| data | Payload to transmit (1–255 bytes). The payload is staged on-chip before this call returns, so the buffer need not outlive the call. |
| invalid_arg | The payload is empty or longer than 255 bytes. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
Definition at line 797 of file lora_transceiver.hpp.
References do_start_transmit(), idfxx::error(), idfxx::invalid_arg, and max_payload_length.
Referenced by start_transmit(), and try_transmit().
|
inline |
Transmits a packet and blocks until completion, sizing the timeout automatically.
Waits at most the packet's time_on_air — computed from the configured link parameters — plus transmit_timeout_margin.
| data | Payload to transmit (1–255 bytes). |
| invalid_arg | The payload is empty or longer than 255 bytes. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
| timeout | The transmit did not complete in time. |
Definition at line 649 of file lora_transceiver.hpp.
References time_on_air(), transmit_timeout_margin, and try_transmit().
Referenced by transmit(), transmit(), and try_transmit().
|
inline |
Transmits a packet and blocks until completion.
Equivalent to try_start_transmit followed by a wait on the returned future. If the transmit does not complete within timeout the radio is returned to standby and errc::timeout is reported.
| data | Payload to transmit (1–255 bytes). |
| timeout | Maximum time to wait for transmit completion. |
| invalid_arg | The payload is empty or longer than 255 bytes. |
| invalid_state | Another transmit, receive, or scan is already in flight. |
| timeout | The transmit did not complete within the specified duration. |
Definition at line 669 of file lora_transceiver.hpp.
References idfxx::error(), idfxx::radio::timeout, and try_start_transmit().
|
staticconstexpr |
Maximum LoRa payload length in bytes.
Definition at line 878 of file lora_transceiver.hpp.
Referenced by try_start_transmit().
|
staticconstexpr |
Guard window for the blocking scan_channel.
Channel-activity detection completes within a few symbol times even at the slowest modulation, so it takes no caller-supplied timeout; the blocking form waits at most this long before cancelling the scan and reporting errc::timeout.
Definition at line 890 of file lora_transceiver.hpp.
Referenced by try_scan_channel().
|
staticconstexpr |
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.
Definition at line 883 of file lora_transceiver.hpp.
Referenced by try_transmit().