| SX126x-Arduino 2.0.1

Data Structures | Typedefs | Functions
Common region implementation

Region independent implementations which are common to all regions. More...

## Data Structures
struct | sRegionCommonLinkAdrParams
struct | sRegionCommonLinkAdrReqVerifyParams
struct | sRegionCommonCalcBackOffParams

## Typedefs
typedef struct sRegionCommonLinkAdrParams | RegionCommonLinkAdrParams_t
typedef struct sRegionCommonLinkAdrReqVerifyParams | RegionCommonLinkAdrReqVerifyParams_t
typedef struct sRegionCommonCalcBackOffParams | RegionCommonCalcBackOffParams_t

## Functions
uint16_t | RegionCommonGetJoinDc (TimerTime_t elapsedTime)
| Calculates the join duty cycle. This is a generic function and valid for all regions. More...
uint8_t | RegionCommonValueInRange (int8_t value, int8_t min, int8_t max)
| Verifies, if a value is in a given range. This is a generic function and valid for all regions. More...
bool | RegionCommonChanVerifyDr (uint8_t nbChannels, uint16_t *channelsMask, int8_t dr, int8_t minDr, int8_t maxDr, ChannelParams_t *channels)
| Verifies, if a datarate is available on an active channel. This is a generic function and valid for all regions. More...
bool | RegionCommonChanDisable (uint16_t *channelsMask, uint8_t id, uint8_t maxChannels)
| Disables a channel in a given channels mask. This is a generic function and valid for all regions. More...
uint8_t | RegionCommonCountChannels (uint16_t *channelsMask, uint8_t startIdx, uint8_t stopIdx)
| Counts the number of active channels in a given channels mask. This is a generic function and valid for all regions. More...
void | RegionCommonChanMaskCopy (uint16_t *channelsMaskDest, uint16_t *channelsMaskSrc, uint8_t len)
| Copy a channels mask. This is a generic function and valid for all regions. More...
void | RegionCommonSetBandTxDone (bool joined, Band_t *band, TimerTime_t lastTxDone)
| Sets the last tx done property. This is a generic function and valid for all regions. More...
TimerTime_t | RegionCommonUpdateBandTimeOff (bool joined, bool dutyCycle, Band_t *bands, uint8_t nbBands)
| Updates the time-offs of the bands. This is a generic function and valid for all regions. More...
uint8_t | RegionCommonParseLinkAdrReq (uint8_t *payload, RegionCommonLinkAdrParams_t *parseLinkAdr)
| Parses the parameter of an LinkAdrRequest. This is a generic function and valid for all regions. More...
uint8_t | RegionCommonLinkAdrReqVerifyParams (RegionCommonLinkAdrReqVerifyParams_t *verifyParams, int8_t *dr, int8_t *txPow, uint8_t *nbRep)
| Verifies and updates the datarate, the TX power and the number of repetitions of a LinkAdrRequest. This depends on the configuration of ADR also. More...
double | RegionCommonComputeSymbolTimeLoRa (uint8_t phyDr, uint32_t bandwidth)
| Computes the symbol time for LoRa modulation. More...
double | RegionCommonComputeSymbolTimeFsk (uint8_t phyDr)
| Computes the symbol time for FSK modulation. More...
void | RegionCommonComputeRxWindowParameters (double tSymbol, uint8_t minRxSymbols, uint32_t rxError, uint32_t wakeUpTime, uint32_t *windowTimeout, int32_t *windowOffset)
| Computes the RX window timeout and the RX window offset. More...
int8_t | RegionCommonComputeTxPower (int8_t txPowerIndex, float maxEirp, float antennaGain)
| Computes the txPower, based on the max EIRP and the antenna gain. More...
void | RegionCommonCalcBackOff (RegionCommonCalcBackOffParams_t *calcBackOffParams)
| Calculates the duty cycle for the current band. More...

## Detailed Description

Region independent implementations which are common to all regions.

## Typedef Documentation

## ◆ RegionCommonLinkAdrParams_t

typedef struct sRegionCommonLinkAdrParams RegionCommonLinkAdrParams_t

## ◆ RegionCommonLinkAdrReqVerifyParams_t

typedef struct sRegionCommonLinkAdrReqVerifyParams RegionCommonLinkAdrReqVerifyParams_t

## ◆ RegionCommonCalcBackOffParams_t

typedef struct sRegionCommonCalcBackOffParams RegionCommonCalcBackOffParams_t

## Function Documentation

## ◆ RegionCommonGetJoinDc()

uint16_t RegionCommonGetJoinDc | ( | TimerTime_t | elapsedTime | ) |

Calculates the join duty cycle. This is a generic function and valid for all regions.

Parameters

  elapsedTime | Elapsed time since the start of the device.

Return values

  Duty | cycle restriction.

## ◆ RegionCommonValueInRange()

uint8_t RegionCommonValueInRange | ( | int8_t | value,
|  | int8_t | min,
|  | int8_t | max
| ) |  |

Verifies, if a value is in a given range. This is a generic function and valid for all regions.

Parameters

  value | Value to verify, if it is in range.
  min | Minimum possible value.
  max | Maximum possible value.

Return values

  Returns | 1 if the value is in range, otherwise 0.

## ◆ RegionCommonChanVerifyDr()

bool RegionCommonChanVerifyDr | ( | uint8_t | nbChannels,
|  | uint16_t * | channelsMask,
|  | int8_t | dr,
|  | int8_t | minDr,
|  | int8_t | maxDr,
|  | ChannelParams_t * | channels
| ) |  |

Verifies, if a datarate is available on an active channel. This is a generic function and valid for all regions.

Parameters

  nbChannels | Number of channels.
  channelsMask | The channels mask of the region.
  dr | The datarate to verify.
  minDr | Minimum datarate.
  maxDr | Maximum datarate.
  channels | The channels of the region.

Return values

  Returns | true if the datarate is supported, false if not.

## ◆ RegionCommonChanDisable()

bool RegionCommonChanDisable | ( | uint16_t * | channelsMask,
|  | uint8_t | id,
|  | uint8_t | maxChannels
| ) |  |

Disables a channel in a given channels mask. This is a generic function and valid for all regions.

Parameters

  channelsMask | The channels mask of the region.
  id | The id of the channels mask to disable.
  maxChannels | Maximum number of channels.

Return values

  Returns | true if the channel could be disabled, false if not.

## ◆ RegionCommonCountChannels()

uint8_t RegionCommonCountChannels | ( | uint16_t * | channelsMask,
|  | uint8_t | startIdx,
|  | uint8_t | stopIdx
| ) |  |

Counts the number of active channels in a given channels mask. This is a generic function and valid for all regions.

Parameters

  channelsMask | The channels mask of the region.
  startIdx | Start index.
  stopIdx | Stop index ( the channels of this index will not be counted ).

Return values

  Returns | the number of active channels.

## ◆ RegionCommonChanMaskCopy()

void RegionCommonChanMaskCopy | ( | uint16_t * | channelsMaskDest,
|  | uint16_t * | channelsMaskSrc,
|  | uint8_t | len
| ) |  |

Copy a channels mask. This is a generic function and valid for all regions.

Parameters

  channelsMaskDest | The destination channels mask.
  channelsMaskSrc | The source channels mask.
  len | The index length to copy.

## ◆ RegionCommonSetBandTxDone()

void RegionCommonSetBandTxDone | ( | bool | joined,
|  | Band_t * | band,
|  | TimerTime_t | lastTxDone
| ) |  |

Sets the last tx done property. This is a generic function and valid for all regions.

Parameters

  joined | Set to true, if the node has joined the network
  band | The band to be updated.
  lastTxDone | The time of the last TX done.

## ◆ RegionCommonUpdateBandTimeOff()

TimerTime_t RegionCommonUpdateBandTimeOff | ( | bool | joined,
|  | bool | dutyCycle,
|  | Band_t * | bands,
|  | uint8_t | nbBands
| ) |  |

Updates the time-offs of the bands. This is a generic function and valid for all regions.

Parameters

  joined | Set to true, if the node has joined the network
  dutyCycle | Set to true, if the duty cycle is enabled.
  bands | A pointer to the bands.
  nbBands | The number of bands available.

Return values

  Returns | the time which must be waited to perform the next uplink.

## ◆ RegionCommonParseLinkAdrReq()

uint8_t RegionCommonParseLinkAdrReq | ( | uint8_t * | payload,
|  | RegionCommonLinkAdrParams_t * | parseLinkAdr
| ) |  |

Parses the parameter of an LinkAdrRequest. This is a generic function and valid for all regions.

Parameters

  payload | Pointer to the payload containing the MAC commands. The payload must contain the CMD identifier, following by the parameters.
  parseLinkAdr | The function fills the structure with the ADR parameters.

Return values

  Returns | the length of the ADR request, if a request was found. Otherwise, the function returns 0.

## ◆ RegionCommonLinkAdrReqVerifyParams()

uint8_t RegionCommonLinkAdrReqVerifyParams | ( | RegionCommonLinkAdrReqVerifyParams_t * | verifyParams,
|  | int8_t * | dr,
|  | int8_t * | txPow,
|  | uint8_t * | nbRep
| ) |  |

Verifies and updates the datarate, the TX power and the number of repetitions of a LinkAdrRequest. This depends on the configuration of ADR also.

Parameters

  verifyParams | Pointer to a structure containing input parameters.
  dr | The updated datarate.
  txPow | The updated TX power.
  nbRep | The updated number of repetitions.

Return values

  Returns | the status according to the LinkAdrRequest definition.

## ◆ RegionCommonComputeSymbolTimeLoRa()

double RegionCommonComputeSymbolTimeLoRa | ( | uint8_t | phyDr,
|  | uint32_t | bandwidth
| ) |  |

Computes the symbol time for LoRa modulation.

Parameters

  phyDr | Physical datarate to use.
  bandwidth | Bandwidth to use.

Return values

  Returns | the symbol time.

## ◆ RegionCommonComputeSymbolTimeFsk()

double RegionCommonComputeSymbolTimeFsk | ( | uint8_t | phyDr | ) |

Computes the symbol time for FSK modulation.

Parameters

  phyDr | Physical datarate to use.

Return values

  Returns | the symbol time.

## ◆ RegionCommonComputeRxWindowParameters()

void RegionCommonComputeRxWindowParameters | ( | double | tSymbol,
|  | uint8_t | minRxSymbols,
|  | uint32_t | rxError,
|  | uint32_t | wakeUpTime,
|  | uint32_t * | windowTimeout,
|  | int32_t * | windowOffset
| ) |  |

Computes the RX window timeout and the RX window offset.

Parameters

  tSymbol | Symbol timeout.
  minRxSymbols | Minimum required number of symbols to detect an Rx frame.
  rxError | System maximum timing error of the receiver. In milliseconds The receiver will turn on in a [-rxError : +rxError] ms interval around RxOffset.
  wakeUpTime | Wakeup time of the system.
  windowTimeout | RX window timeout.
  windowOffset | RX window time offset to be applied to the RX delay.

## ◆ RegionCommonComputeTxPower()

int8_t RegionCommonComputeTxPower | ( | int8_t | txPowerIndex,
|  | float | maxEirp,
|  | float | antennaGain
| ) |  |

Computes the txPower, based on the max EIRP and the antenna gain.

Parameters

  txPowerIndex | TX power index.
  maxEirp | Maximum EIRP.
  antennaGain | Antenna gain.

Return values

  Returns | the physical TX power.

## ◆ RegionCommonCalcBackOff()

void RegionCommonCalcBackOff | ( | RegionCommonCalcBackOffParams_t * | calcBackOffParams | ) |

Calculates the duty cycle for the current band.

Parameters

  calcBackOffParams | A pointer to the input parameters.