Mbed OS Reference
Loading...
Searching...
No Matches
LoRaRadio Class Referenceabstract

Interface for the radios, containing the main functions that a radio needs, and five callback functions. More...

#include <LoRaRadio.h>

Inheritance diagram for LoRaRadio:
STM32WL_LoRaRadio SX126X_LoRaRadio SX1272_LoRaRadio SX1276_LoRaRadio

Public Member Functions

virtual void init_radio (radio_events_t *events)=0
 Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps, if any. More...
 
virtual void radio_reset ()=0
 Resets the radio module. More...
 
virtual void sleep (void)=0
 Put the RF module in sleep mode. More...
 
virtual void standby (void)=0
 Sets the radio to standby mode. More...
 
virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidth_afc, uint16_t preamble_len, uint16_t symb_timeout, bool fix_len, uint8_t payload_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, bool rx_continuous)=0
 Sets reception parameters. More...
 
virtual void set_tx_config (radio_modems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preamble_len, bool fix_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, uint32_t timeout)=0
 Sets the transmission parameters. More...
 
virtual void send (uint8_t *buffer, uint8_t size)=0
 Sends the packet. More...
 
virtual void receive (void)=0
 Sets the radio to reception mode. More...
 
virtual void set_channel (uint32_t freq)=0
 Sets the carrier frequency. More...
 
virtual uint32_t random (void)=0
 Generates a 32 bit random value based on RSSI readings. More...
 
virtual radio_state_t get_status (void)=0
 Gets the radio status. More...
 
virtual void set_max_payload_length (radio_modems_t modem, uint8_t max)=0
 Sets the maximum payload length. More...
 
virtual void set_public_network (bool enable)=0
 Sets the network to public or private. More...
 
virtual uint32_t time_on_air (radio_modems_t modem, uint8_t pkt_len)=0
 Computes the packet time on air for the given payload. More...
 
virtual bool perform_carrier_sense (radio_modems_t modem, uint32_t freq, int16_t rssi_threshold, uint32_t max_carrier_sense_time)=0
 Performs carrier sensing. More...
 
virtual void start_cad (void)=0
 Sets the radio to CAD mode. More...
 
virtual bool check_rf_frequency (uint32_t frequency)=0
 Checks whether the given RF is in range. More...
 
virtual void set_tx_continuous_wave (uint32_t freq, int8_t power, uint16_t time)=0
 Sets the radio to continuous wave transmission mode. More...
 
virtual void lock (void)=0
 Acquires exclusive access to this radio. More...
 
virtual void unlock (void)=0
 Releases exclusive access to this radio. More...
 

Detailed Description

Interface for the radios, containing the main functions that a radio needs, and five callback functions.

Definition at line 441 of file LoRaRadio.h.

Member Function Documentation

◆ init_radio()

virtual void init_radio ( radio_events_t events)
pure virtual

Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps, if any.

Parameters
eventsContains driver callback functions.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ radio_reset()

virtual void radio_reset ( )
pure virtual

Resets the radio module.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ sleep()

virtual void sleep ( void  )
pure virtual

Put the RF module in sleep mode.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ standby()

virtual void standby ( void  )
pure virtual

Sets the radio to standby mode.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_rx_config()

virtual void set_rx_config ( radio_modems_t  modem,
uint32_t  bandwidth,
uint32_t  datarate,
uint8_t  coderate,
uint32_t  bandwidth_afc,
uint16_t  preamble_len,
uint16_t  symb_timeout,
bool  fix_len,
uint8_t  payload_len,
bool  crc_on,
bool  freq_hop_on,
uint8_t  hop_period,
bool  iq_inverted,
bool  rx_continuous 
)
pure virtual

Sets reception parameters.

Parameters
modemThe radio modem [0: FSK, 1: LoRa].
bandwidthSets the bandwidth. FSK : >= 2600 and <= 250000 Hz LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
datarateSets the datarate. FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
coderateSets the coding rate (LoRa only). FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
bandwidth_afcSets the AFC bandwidth (FSK only). FSK : >= 2600 and <= 250000 Hz LoRa: N/A (set to 0)
preamble_lenSets the preamble length (LoRa only). FSK : N/A (set to 0) LoRa: Length in symbols (the hardware adds four more symbols).
symb_timeoutSets the RxSingle timeout value. FSK : Timeout number of bytes LoRa: Timeout in symbols
fix_lenFixed length packets [0: variable, 1: fixed].
payload_lenSets the payload length when fixed length is used.
crc_onEnables/disables CRC [0: OFF, 1: ON].
freq_hop_onEnables/disables intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only).
hop_periodThe number of symbols bewteen each hop (LoRa only).
iq_invertedInverts the IQ signals (LoRa only). FSK : N/A (set to 0) LoRa: [0: not inverted, 1: inverted]
rx_continuousSets the reception to continuous mode. [false: single mode, true: continuous mode]

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_tx_config()

virtual void set_tx_config ( radio_modems_t  modem,
int8_t  power,
uint32_t  fdev,
uint32_t  bandwidth,
uint32_t  datarate,
uint8_t  coderate,
uint16_t  preamble_len,
bool  fix_len,
bool  crc_on,
bool  freq_hop_on,
uint8_t  hop_period,
bool  iq_inverted,
uint32_t  timeout 
)
pure virtual

Sets the transmission parameters.

Parameters
modemThe radio modem [0: FSK, 1: LoRa].
powerSets the output power [dBm].
fdevSets the frequency deviation (FSK only). FSK : [Hz] LoRa: 0
bandwidthSets the bandwidth (LoRa only). FSK : 0 LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
datarateSets the datarate. FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
coderateSets the coding rate (LoRa only). FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
preamble_lenSets the preamble length.
fix_lenFixed length packets [0: variable, 1: fixed].
crc_onEnables/disables CRC [0: OFF, 1: ON].
freq_hop_onEnables/disables intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only).
hop_periodThe number of symbols between each hop (LoRa only).
iq_invertedInverts IQ signals (LoRa only) FSK : N/A (set to 0). LoRa: [0: not inverted, 1: inverted]
timeoutThe transmission timeout [ms].

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ send()

virtual void send ( uint8_t *  buffer,
uint8_t  size 
)
pure virtual

Sends the packet.

Prepares the packet to be sent and sets the radio to transmission mode.

Parameters
bufferA pointer to the buffer.
sizeThe buffer size.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ receive()

virtual void receive ( void  )
pure virtual

Sets the radio to reception mode.

To configure the receiver, use the set_rx_config() API.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_channel()

virtual void set_channel ( uint32_t  freq)
pure virtual

Sets the carrier frequency.

Parameters
freqChannel RF frequency.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ random()

virtual uint32_t random ( void  )
pure virtual

Generates a 32 bit random value based on RSSI readings.

Remarks
This function sets the radio in LoRa modem mode and disables all interrupts. After calling this function, either Radio.SetRxConfig or Radio.SetTxConfig functions must be called.
Returns
A 32 bit random value.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ get_status()

virtual radio_state_t get_status ( void  )
pure virtual

Gets the radio status.

Returns
The current radio status (RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING, etc.)

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_max_payload_length()

virtual void set_max_payload_length ( radio_modems_t  modem,
uint8_t  max 
)
pure virtual

Sets the maximum payload length.

Parameters
modemThe radio modem [0: FSK, 1: LoRa].
maxThe maximum payload length in bytes.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_public_network()

virtual void set_public_network ( bool  enable)
pure virtual

Sets the network to public or private.

Updates the sync byte. Applies to LoRa modem only.

Parameters
enableIf true, enables a public network.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ time_on_air()

virtual uint32_t time_on_air ( radio_modems_t  modem,
uint8_t  pkt_len 
)
pure virtual

Computes the packet time on air for the given payload.

Remarks
This can only be called after SetRxConfig or SetTxConfig.
Parameters
modemThe radio modem [0: FSK, 1: LoRa].
pkt_lenThe packet payload length.
Returns
The computed airTime for the given packet payload length.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ perform_carrier_sense()

virtual bool perform_carrier_sense ( radio_modems_t  modem,
uint32_t  freq,
int16_t  rssi_threshold,
uint32_t  max_carrier_sense_time 
)
pure virtual

Performs carrier sensing.

Checks for a certain time if the RSSI is above a given threshold. This threshold determines whether or not there is a transmission on the channel already.

Parameters
modemThe type of radio modem.
freqThe carrier frequency.
rssi_thresholdThe threshold value of RSSI.
max_carrier_sense_timeThe time set for sensing the channel (ms).
Returns
True if there is no active transmission in the channel, otherwise false.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ start_cad()

virtual void start_cad ( void  )
pure virtual

Sets the radio to CAD mode.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ check_rf_frequency()

virtual bool check_rf_frequency ( uint32_t  frequency)
pure virtual

Checks whether the given RF is in range.

Parameters
frequencyThe frequency to check.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ set_tx_continuous_wave()

virtual void set_tx_continuous_wave ( uint32_t  freq,
int8_t  power,
uint16_t  time 
)
pure virtual

Sets the radio to continuous wave transmission mode.

Parameters
freqThe RF frequency of the channel.
powerThe output power [dBm].
timeThe transmission mode timeout [s].

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ lock()

virtual void lock ( void  )
pure virtual

Acquires exclusive access to this radio.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.

◆ unlock()

virtual void unlock ( void  )
pure virtual

Releases exclusive access to this radio.

Implemented in SX126X_LoRaRadio, SX1272_LoRaRadio, SX1276_LoRaRadio, and STM32WL_LoRaRadio.