| SX126x-Arduino 2.0.1

Data Fields
Radio_s Struct Reference

Radio driver definition. More...

`#include <radio.h>`

## Data Fields
void(* | Init )(RadioEvents_t *events)
| Initializes the radio. More...
void(* | ReInit )(RadioEvents_t *events)
| Re-Initializes the radio after CPU wakeup from deep sleep. More...
RadioState_t(* | GetStatus )(void)
void(* | SetModem )(RadioModems_t modem)
| Configures the radio with the given modem. More...
void(* | SetChannel )(uint32_t freq)
| Sets the channel frequency. More...
bool(* | IsChannelFree )(RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t maxCarrierSenseTime)
| Checks if the channel is free for the given time. More...
uint32_t(* | Random )(void)
| Generates a 32 bits random value based on the RSSI readings. More...
void(* | SetRxConfig )(RadioModems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidthAfc, uint16_t preambleLen, uint16_t symbTimeout, bool fixLen, uint8_t payloadLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, bool rxContinuous)
| Sets the reception parameters. More...
void(* | SetTxConfig )(RadioModems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preambleLen, bool fixLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, uint32_t timeout)
| Sets the transmission parameters. More...
bool(* | CheckRfFrequency )(uint32_t frequency)
| Checks if the given RF frequency is supported by the hardware. More...
uint32_t(* | TimeOnAir )(RadioModems_t modem, uint8_t pktLen)
| Computes the packet time on air in ms for the given payload. More...
void(* | Send )(uint8_t *buffer, uint8_t size)
| Sends the buffer of size. Prepares the packet to be sent and sets the radio in transmission. More...
void(* | Sleep )(void)
| Sets the radio in sleep mode. More...
void(* | Standby )(void)
| Sets the radio in standby mode. More...
void(* | Rx )(uint32_t timeout)
| Sets the radio in reception mode for the given time. More...
void(* | SetCadParams )(uint8_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, uint8_t cadExitMode, uint32_t cadTimeout)
| Set Channel Activity Detection parameters. More...
void(* | StartCad )(void)
| Start a Channel Activity Detection. More...
void(* | SetTxContinuousWave )(uint32_t freq, int8_t power, uint16_t time)
| Sets the radio in continuous wave transmission mode. More...
int16_t(* | Rssi )(RadioModems_t modem)
| Reads the current RSSI value. More...
void(* | Write )(uint16_t addr, uint8_t data)
| Writes the radio register at the specified address. More...
uint8_t(* | Read )(uint16_t addr)
| Reads the radio register at the specified address. More...
void(* | WriteBuffer )(uint16_t addr, uint8_t *buffer, uint8_t size)
| Writes multiple radio registers starting at address. More...
void(* | ReadBuffer )(uint16_t addr, uint8_t *buffer, uint8_t size)
| Reads multiple radio registers starting at address. More...
void(* | SetMaxPayloadLength )(RadioModems_t modem, uint8_t max)
| Sets the maximum payload length. More...
void(* | SetPublicNetwork )(bool enable)
| Sets the network to public or private. Updates the sync byte. More...
uint32_t(* | GetWakeupTime )(void)
| Gets the time required for the board plus radio to get out of sleep.[ms]. More...
void(* | BgIrqProcess )(void)
| Process radio irq in background task (nRF52 & ESP32) More...
void(* | IrqProcess )(void)
| Process radio irq. More...
void(* | IrqProcessAfterDeepSleep )(void)
void(* | RxBoosted )(uint32_t timeout)
| Sets the radio in reception mode with Max LNA gain for the given time. More...
void(* | SetRxDutyCycle )(uint32_t rxTime, uint32_t sleepTime)
| Sets the Rx duty cycle management parameters. More...

## Detailed Description

Radio driver definition.

## Field Documentation

## ◆ Init

void(* Radio_s::Init) (RadioEvents_t *events)

Initializes the radio.

Parameters

  events | Structure containing the driver callback functions

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ ReInit

void(* Radio_s::ReInit) (RadioEvents_t *events)

Re-Initializes the radio after CPU wakeup from deep sleep.

Parameters

  events | Structure containing the driver callback functions

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp.

## ◆ GetStatus

RadioState_t(* Radio_s::GetStatus) (void)

Return current radio status

Parameters

  status | Radio status.[RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING]

## ◆ SetModem

void(* Radio_s::SetModem) (RadioModems_t modem)

Configures the radio with the given modem.

Parameters

  modem | Modem to be used [0: FSK, 1: LoRa]

## ◆ SetChannel

void(* Radio_s::SetChannel) (uint32_t freq)

Sets the channel frequency.

Parameters

  freq | Channel RF frequency

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ IsChannelFree

bool(* Radio_s::IsChannelFree) (RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t maxCarrierSenseTime)

Checks if the channel is free for the given time.

Parameters

  modem | Radio modem to be used [0: FSK, 1: LoRa]
  freq | Channel RF frequency
  rssiThresh | RSSI threshold
  maxCarrierSenseTime | Max time while the RSSI is measured

Return values

  isFree | [true: Channel is free, false: Channel is not free]

## ◆ Random

uint32_t(* Radio_s::Random) (void)

Generates a 32 bits random value based on the 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.

Return values

  randomValue | 32 bits random value

## ◆ SetRxConfig

void(* Radio_s::SetRxConfig) (RadioModems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidthAfc, uint16_t preambleLen, uint16_t symbTimeout, bool fixLen, uint8_t payloadLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, bool rxContinuous)

Sets the reception parameters.

Parameters

  modem | Radio modem to be used [0: FSK, 1: LoRa]
  bandwidth | Sets the bandwidth FSK : >= 2600 and <= 250000 Hz LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
  datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
  coderate | Sets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
  bandwidthAfc | Sets the AFC Bandwidth (FSK only) FSK : >= 2600 and <= 250000 Hz LoRa: N/A ( set to 0 )
  preambleLen | Sets the Preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols)
  symbTimeout | Sets the RxSingle timeout value FSK : timeout in number of bytes LoRa: timeout in symbols
  fixLen | Fixed length packets [0: variable, 1: fixed]
  payloadLen | Sets payload length when fixed length is used
  crcOn | Enables/Disables the CRC [0: OFF, 1: ON]
  freqHopOn | Enables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [0: OFF, 1: ON]
  hopPeriod | Number of symbols between each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols
  iqInverted | Inverts IQ signals (LoRa only) FSK : N/A ( set to 0 ) LoRa: [0: not inverted, 1: inverted]
  rxContinuous | Sets the reception in continuous mode [false: single mode, true: continuous mode]

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ SetTxConfig

void(* Radio_s::SetTxConfig) (RadioModems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preambleLen, bool fixLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, uint32_t timeout)

Sets the transmission parameters.

Parameters

  modem | Radio modem to be used [0: FSK, 1: LoRa]
  power | Sets the output power [dBm]
  fdev | Sets the frequency deviation (FSK only) FSK : [Hz] LoRa: 0
  bandwidth | Sets the bandwidth (LoRa only) FSK : 0 LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
  datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
  coderate | Sets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
  preambleLen | Sets the preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols)
  fixLen | Fixed length packets [0: variable, 1: fixed]
  crcOn | Enables disables the CRC [0: OFF, 1: ON]
  freqHopOn | Enables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [0: OFF, 1: ON]
  hopPeriod | Number of symbols between each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols
  iqInverted | Inverts IQ signals (LoRa only) FSK : N/A ( set to 0 ) LoRa: [0: not inverted, 1: inverted]
  timeout | Transmission timeout [ms]

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ CheckRfFrequency

bool(* Radio_s::CheckRfFrequency) (uint32_t frequency)

Checks if the given RF frequency is supported by the hardware.

Parameters

  frequency | RF frequency to be checked

Return values

  isSupported | [true: supported, false: unsupported]

## ◆ TimeOnAir

uint32_t(* Radio_s::TimeOnAir) (RadioModems_t modem, uint8_t pktLen)

Computes the packet time on air in ms for the given payload.

Remarks
  Can only be called once SetRxConfig or SetTxConfig have been called

Parameters

  modem | Radio modem to be used [0: FSK, 1: LoRa]
  pktLen | Packet payload length

Return values

  airTime | Computed airTime (ms) for the given packet payload length

## ◆ Send

void(* Radio_s::Send) (uint8_t *buffer, uint8_t size)

Sends the buffer of size. Prepares the packet to be sent and sets the radio in transmission.

Parameters

  buffer | Buffer pointer
  size | Buffer size

Examples
  Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ Sleep

void(* Radio_s::Sleep) (void)

Sets the radio in sleep mode.

Examples
  Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ Standby

void(* Radio_s::Standby) (void)

Sets the radio in standby mode.

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ Rx

void(* Radio_s::Rx) (uint32_t timeout)

Sets the radio in reception mode for the given time.

Parameters

  timeout | Reception timeout [ms] [0: continuous, others timeout]

## ◆ SetCadParams

void(* Radio_s::SetCadParams) (uint8_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, uint8_t cadExitMode, uint32_t cadTimeout)

Set Channel Activity Detection parameters.

Examples
  Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ StartCad

void(* Radio_s::StartCad) (void)

Start a Channel Activity Detection.

Examples
  Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ SetTxContinuousWave

void(* Radio_s::SetTxContinuousWave) (uint32_t freq, int8_t power, uint16_t time)

Sets the radio in continuous wave transmission mode.

Parameters

  freq | Channel RF frequency
  power | Sets the output power [dBm]
  time | Transmission mode timeout [s]

## ◆ Rssi

int16_t(* Radio_s::Rssi) (RadioModems_t modem)

Reads the current RSSI value.

Return values

  rssiValue | Current RSSI value in [dBm]

## ◆ Write

void(* Radio_s::Write) (uint16_t addr, uint8_t data)

Writes the radio register at the specified address.

Parameters

  addr | Register address
  data | New register value

## ◆ Read

uint8_t(* Radio_s::Read) (uint16_t addr)

Reads the radio register at the specified address.

Parameters

  addr | Register address

Return values

  data | Register value

## ◆ WriteBuffer

void(* Radio_s::WriteBuffer) (uint16_t addr, uint8_t *buffer, uint8_t size)

Writes multiple radio registers starting at address.

Parameters

  addr | First Radio register address
  buffer | Buffer containing the new register's values
  size | Number of registers to be written

## ◆ ReadBuffer

void(* Radio_s::ReadBuffer) (uint16_t addr, uint8_t *buffer, uint8_t size)

Reads multiple radio registers starting at address.

Parameters

  addr | First Radio register address
  buffer | Buffer where to copy the registers data
  size | Number of registers to be read

## ◆ SetMaxPayloadLength

void(* Radio_s::SetMaxPayloadLength) (RadioModems_t modem, uint8_t max)

Sets the maximum payload length.

Parameters

  modem | Radio modem to be used [0: FSK, 1: LoRa]
  max | Maximum payload length in bytes

## ◆ SetPublicNetwork

void(* Radio_s::SetPublicNetwork) (bool enable)

Sets the network to public or private. Updates the sync byte.

Remarks
  Applies to LoRa modem only

Parameters

  enable | if true, it enables a public network

## ◆ GetWakeupTime

uint32_t(* Radio_s::GetWakeupTime) (void)

Gets the time required for the board plus radio to get out of sleep.[ms].

Return values

  time | Radio plus board wakeup time in ms.

## ◆ BgIrqProcess

void(* Radio_s::BgIrqProcess) (void)

Process radio irq in background task (nRF52 & ESP32)

## ◆ IrqProcess

void(* Radio_s::IrqProcess) (void)

Process radio irq.

Examples
  LoRaWanPio\src\main.cpp, and Sensor-Gateway-Deepsleep\LoRa-TempSensor\src\main.cpp.

## ◆ IrqProcessAfterDeepSleep

void(* Radio_s::IrqProcessAfterDeepSleep) (void)

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp.

## ◆ RxBoosted

void(* Radio_s::RxBoosted) (uint32_t timeout)

Sets the radio in reception mode with Max LNA gain for the given time.

Remarks
  Available on SX126x radios only.

Parameters

  timeout | Reception timeout [ms] [0: continuous, others timeout]

## ◆ SetRxDutyCycle

void(* Radio_s::SetRxDutyCycle) (uint32_t rxTime, uint32_t sleepTime)

Sets the Rx duty cycle management parameters.

Remarks
  Available on SX126x radios only.

Parameters

  rxTime | Structure describing reception timeout value
  sleepTime | Structure describing sleep timeout value

Examples
  Sensor-Gateway-Deepsleep\LoRa-Gateway\src\main.cpp.

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

- src/radio/radio.h