| SX126x-Arduino 2.0.1

RegionCommon.h
Go to the documentation of this file.
1
35 #ifndef __REGIONCOMMON_H__
36 #define __REGIONCOMMON_H__
37
38 extern "C"
39 {
40
41 typedef struct sRegionCommonLinkAdrParams
42 {
46 uint8_t NbRep;
50 int8_t Datarate;
54 int8_t TxPower;
58 uint8_t ChMaskCtrl;
62 uint16_t ChMask;
63 } RegionCommonLinkAdrParams_t;
64
65 typedef struct sRegionCommonLinkAdrReqVerifyParams
66 {
70 uint8_t Status;
74 bool AdrEnabled;
78 int8_t Datarate;
82 int8_t TxPower;
86 uint8_t NbRep;
90 int8_t CurrentDatarate;
94 int8_t CurrentTxPower;
98 int8_t CurrentNbRep;
102 uint8_t NbChannels;
106 uint16_t *ChannelsMask;
110 int8_t MinDatarate;
114 int8_t MaxDatarate;
118 ChannelParams_t *Channels;
122 int8_t MinTxPower;
126 int8_t MaxTxPower;
127 } RegionCommonLinkAdrReqVerifyParams_t;
128
129 typedef struct sRegionCommonCalcBackOffParams
130 {
134 ChannelParams_t *Channels;
138 Band_t *Bands;
142 bool LastTxIsJoinRequest;
146 bool Joined;
150 bool DutyCycleEnabled;
154 uint8_t Channel;
158 TimerTime_t ElapsedTime;
162 TimerTime_t TxTimeOnAir;
163 } RegionCommonCalcBackOffParams_t;
164
173 uint16_t RegionCommonGetJoinDc(TimerTime_t elapsedTime);
174
187 uint8_t RegionCommonValueInRange(int8_t value, int8_t min, int8_t max);
188
207 bool RegionCommonChanVerifyDr(uint8_t nbChannels, uint16_t *channelsMask, int8_t dr,
208 int8_t minDr, int8_t maxDr, ChannelParams_t *channels);
209
222 bool RegionCommonChanDisable(uint16_t *channelsMask, uint8_t id, uint8_t maxChannels);
223
236 uint8_t RegionCommonCountChannels(uint16_t *channelsMask, uint8_t startIdx, uint8_t stopIdx);
237
248 void RegionCommonChanMaskCopy(uint16_t *channelsMaskDest, uint16_t *channelsMaskSrc, uint8_t len);
249
260 void RegionCommonSetBandTxDone(bool joined, Band_t *band, TimerTime_t lastTxDone);
261
276 TimerTime_t RegionCommonUpdateBandTimeOff(bool joined, bool dutyCycle, Band_t *bands, uint8_t nbBands);
277
290 uint8_t RegionCommonParseLinkAdrReq(uint8_t *payload, RegionCommonLinkAdrParams_t *parseLinkAdr);
291
306 uint8_t RegionCommonLinkAdrReqVerifyParams(RegionCommonLinkAdrReqVerifyParams_t *verifyParams, int8_t *dr, int8_t *txPow, uint8_t *nbRep);
307
317 double RegionCommonComputeSymbolTimeLoRa(uint8_t phyDr, uint32_t bandwidth);
318
326 double RegionCommonComputeSymbolTimeFsk(uint8_t phyDr);
327
344 void RegionCommonComputeRxWindowParameters(double tSymbol, uint8_t minRxSymbols, uint32_t rxError, uint32_t wakeUpTime, uint32_t *windowTimeout, int32_t *windowOffset);
345
357 int8_t RegionCommonComputeTxPower(int8_t txPowerIndex, float maxEirp, float antennaGain);
358
364 void RegionCommonCalcBackOff(RegionCommonCalcBackOffParams_t *calcBackOffParams);
365
367 };
368 #endif // __REGIONCOMMON_H__
sRegionCommonLinkAdrReqVerifyParams::CurrentTxPower
int8_t CurrentTxPower
Definition: RegionCommon.h:94
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.
Definition: RegionCommon.cpp:161
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 f...
Definition: RegionCommon.cpp:120
sBand
Definition: LoRaMac.h:144
RegionCommonComputeTxPower
int8_t RegionCommonComputeTxPower(int8_t txPowerIndex, float maxEirp, float antennaGain)
Computes the txPower, based on the max EIRP and the antenna gain.
Definition: RegionCommon.cpp:309
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.
Definition: RegionCommon.cpp:96
sRegionCommonCalcBackOffParams::ElapsedTime
TimerTime_t ElapsedTime
Definition: RegionCommon.h:158
sRegionCommonCalcBackOffParams::TxTimeOnAir
TimerTime_t TxTimeOnAir
Definition: RegionCommon.h:162
sRegionCommonLinkAdrReqVerifyParams::MaxTxPower
int8_t MaxTxPower
Definition: RegionCommon.h:126
sRegionCommonCalcBackOffParams::LastTxIsJoinRequest
bool LastTxIsJoinRequest
Definition: RegionCommon.h:142
sRegionCommonLinkAdrParams::ChMaskCtrl
uint8_t ChMaskCtrl
Definition: RegionCommon.h:58
sRegionCommonLinkAdrReqVerifyParams::Datarate
int8_t Datarate
Definition: RegionCommon.h:78
sRegionCommonLinkAdrReqVerifyParams
Definition: RegionCommon.h:66
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.
Definition: RegionCommon.cpp:148
sRegionCommonLinkAdrReqVerifyParams::MinTxPower
int8_t MinTxPower
Definition: RegionCommon.h:122
sChannelParams
Definition: LoRaMac.h:171
sRegionCommonLinkAdrParams::Datarate
int8_t Datarate
Definition: RegionCommon.h:50
sRegionCommonLinkAdrReqVerifyParams::Channels
ChannelParams_t * Channels
Definition: RegionCommon.h:118
sRegionCommonLinkAdrReqVerifyParams::MinDatarate
int8_t MinDatarate
Definition: RegionCommon.h:110
RegionCommonGetJoinDc
uint16_t RegionCommonGetJoinDc(TimerTime_t elapsedTime)
Calculates the join duty cycle. This is a generic function and valid for all regions.
Definition: RegionCommon.cpp:52
sRegionCommonLinkAdrParams::ChMask
uint16_t ChMask
Definition: RegionCommon.h:62
sRegionCommonCalcBackOffParams::Joined
bool Joined
Definition: RegionCommon.h:146
sRegionCommonLinkAdrReqVerifyParams::CurrentNbRep
int8_t CurrentNbRep
Definition: RegionCommon.h:98
sRegionCommonLinkAdrParams::TxPower
int8_t TxPower
Definition: RegionCommon.h:54
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.
Definition: RegionCommon.cpp:303
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.
Definition: RegionCommon.cpp:137
RegionCommonLinkAdrReqVerifyParams_t
struct sRegionCommonLinkAdrReqVerifyParams RegionCommonLinkAdrReqVerifyParams_t
sRegionCommonCalcBackOffParams::DutyCycleEnabled
bool DutyCycleEnabled
Definition: RegionCommon.h:150
sRegionCommonLinkAdrReqVerifyParams::NbChannels
uint8_t NbChannels
Definition: RegionCommon.h:102
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.
Definition: RegionCommon.cpp:206
sRegionCommonCalcBackOffParams::Bands
Band_t * Bands
Definition: RegionCommon.h:138
sRegionCommonCalcBackOffParams::Channel
uint8_t Channel
Definition: RegionCommon.h:154
RegionCommonComputeSymbolTimeLoRa
double RegionCommonComputeSymbolTimeLoRa(uint8_t phyDr, uint32_t bandwidth)
Computes the symbol time for LoRa modulation.
Definition: RegionCommon.cpp:293
RegionCommonComputeSymbolTimeFsk
double RegionCommonComputeSymbolTimeFsk(uint8_t phyDr)
Computes the symbol time for FSK modulation.
Definition: RegionCommon.cpp:298
sRegionCommonCalcBackOffParams::Channels
ChannelParams_t * Channels
Definition: RegionCommon.h:134
sRegionCommonCalcBackOffParams
Definition: RegionCommon.h:130
sRegionCommonLinkAdrReqVerifyParams::NbRep
uint8_t NbRep
Definition: RegionCommon.h:86
RegionCommonCalcBackOffParams_t
struct sRegionCommonCalcBackOffParams RegionCommonCalcBackOffParams_t
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....
Definition: RegionCommon.cpp:230
sRegionCommonLinkAdrReqVerifyParams::CurrentDatarate
int8_t CurrentDatarate
Definition: RegionCommon.h:90
sRegionCommonLinkAdrParams
Definition: RegionCommon.h:42
sRegionCommonLinkAdrReqVerifyParams::ChannelsMask
uint16_t * ChannelsMask
Definition: RegionCommon.h:106
sRegionCommonLinkAdrReqVerifyParams::MaxDatarate
int8_t MaxDatarate
Definition: RegionCommon.h:114
sRegionCommonLinkAdrReqVerifyParams::TxPower
int8_t TxPower
Definition: RegionCommon.h:82
RegionCommonCalcBackOff
void RegionCommonCalcBackOff(RegionCommonCalcBackOffParams_t *calcBackOffParams)
Calculates the duty cycle for the current band.
Definition: RegionCommon.cpp:318
sRegionCommonLinkAdrReqVerifyParams::AdrEnabled
bool AdrEnabled
Definition: RegionCommon.h:74
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 a...
Definition: RegionCommon.cpp:71
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.
Definition: RegionCommon.cpp:105
sRegionCommonLinkAdrParams::NbRep
uint8_t NbRep
Definition: RegionCommon.h:46
TimerTime_t
uint32_t TimerTime_t
Timer time variable definition.
Definition: timer.h:69
sRegionCommonLinkAdrReqVerifyParams::Status
uint8_t Status
Definition: RegionCommon.h:70
RegionCommonLinkAdrParams_t
struct sRegionCommonLinkAdrParams RegionCommonLinkAdrParams_t