kopia lustrzana https://github.com/jgromes/RadioLib
[LoRaWAN] Simplify JoinRequest datarate handling
rodzic
855a64c053
commit
3e634ffb88
|
@ -346,15 +346,9 @@ void LoRaWANNode::createSession(uint16_t lwMode, uint8_t initialDr) {
|
|||
}
|
||||
|
||||
// if there is no (channel that allowed the) user-specified datarate, use a default datarate
|
||||
// we use the floor of the average datarate of the first enabled channel
|
||||
if(initialDr == RADIOLIB_LORAWAN_DATA_RATE_UNUSED) {
|
||||
for(int i = 0; i < RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS; i++) {
|
||||
if(this->channelPlan[RADIOLIB_LORAWAN_UPLINK][i].enabled) {
|
||||
uint8_t drMin = this->channelPlan[RADIOLIB_LORAWAN_UPLINK][i].drMin;
|
||||
uint8_t drMax = this->channelPlan[RADIOLIB_LORAWAN_UPLINK][i].drMax;
|
||||
drUp = (drMin + drMax) / 2;
|
||||
}
|
||||
}
|
||||
// use the specified datarate from the first channel (this is always defined)
|
||||
drUp = this->channelPlan[RADIOLIB_LORAWAN_UPLINK][0].dr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2980,15 +2974,6 @@ void LoRaWANNode::selectChannelPlanDyn(bool joinRequest) {
|
|||
this->channelPlan[RADIOLIB_LORAWAN_DOWNLINK][num] = this->band->txFreqs[num];
|
||||
}
|
||||
|
||||
// if we're about to send a JoinRequest, copy the JoinRequest channels to the next slots
|
||||
if(joinRequest) {
|
||||
size_t numJR = 0;
|
||||
for(; numJR < 3 && this->band->txJoinReq[num].enabled; numJR++, num++) {
|
||||
this->channelPlan[RADIOLIB_LORAWAN_UPLINK][num] = this->band->txFreqs[num];
|
||||
this->channelPlan[RADIOLIB_LORAWAN_DOWNLINK][num] = this->band->txFreqs[num];
|
||||
}
|
||||
}
|
||||
|
||||
// clear all remaining channels
|
||||
for(; num < RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS; num++) {
|
||||
this->channelPlan[RADIOLIB_LORAWAN_UPLINK][num] = RADIOLIB_LORAWAN_CHANNEL_NONE;
|
||||
|
|
|
@ -405,9 +405,6 @@ struct LoRaWANBand_t {
|
|||
/*! \brief A set of default uplink (TX) channels for dynamic bands */
|
||||
LoRaWANChannel_t txFreqs[3];
|
||||
|
||||
/*! \brief A set of possible extra channels for the Join-Request message for dynamic bands */
|
||||
LoRaWANChannel_t txJoinReq[3];
|
||||
|
||||
/*! \brief The number of TX channel spans for fixed bands */
|
||||
uint8_t numTxSpans;
|
||||
|
||||
|
|
|
@ -30,14 +30,9 @@ const LoRaWANBand_t EU868 = {
|
|||
.dwellTimeDn = 0,
|
||||
.txParamSupported = false,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 8681000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 8683000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 8685000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
{ .enabled = true, .idx = 0, .freq = 8681000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 8683000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 8685000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
.txSpans = {
|
||||
|
@ -107,11 +102,6 @@ const LoRaWANBand_t US915 = {
|
|||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 2,
|
||||
.txSpans = {
|
||||
{
|
||||
|
@ -197,14 +187,9 @@ const LoRaWANBand_t EU433 = {
|
|||
.dwellTimeDn = 0,
|
||||
.txParamSupported = false,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 4331750, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 4333750, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 4335750, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
{ .enabled = true, .idx = 0, .freq = 4331750, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 4333750, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 4335750, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
.txSpans = {
|
||||
|
@ -274,11 +259,6 @@ const LoRaWANBand_t AU915 = {
|
|||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 2,
|
||||
.txSpans = {
|
||||
{
|
||||
|
@ -368,11 +348,6 @@ const LoRaWANBand_t CN500 = {
|
|||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 1,
|
||||
.txSpans = {
|
||||
{
|
||||
|
@ -451,13 +426,8 @@ const LoRaWANBand_t AS923 = {
|
|||
.dwellTimeDn = RADIOLIB_LORAWAN_DWELL_TIME,
|
||||
.txParamSupported = true,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 9232000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9234000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
{ .enabled = true, .idx = 0, .freq = 9232000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9234000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
|
@ -524,13 +494,8 @@ const LoRaWANBand_t AS923_2 = {
|
|||
.dwellTimeDn = RADIOLIB_LORAWAN_DWELL_TIME,
|
||||
.txParamSupported = true,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 9214000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9216000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
{ .enabled = true, .idx = 0, .freq = 9214000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9216000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
|
@ -597,13 +562,8 @@ const LoRaWANBand_t AS923_3 = {
|
|||
.dwellTimeDn = RADIOLIB_LORAWAN_DWELL_TIME,
|
||||
.txParamSupported = true,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 9166000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9168000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
{ .enabled = true, .idx = 0, .freq = 9166000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9168000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
|
@ -670,13 +630,8 @@ const LoRaWANBand_t AS923_4 = {
|
|||
.dwellTimeDn = RADIOLIB_LORAWAN_DWELL_TIME,
|
||||
.txParamSupported = true,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 9173000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9175000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
{ .enabled = true, .idx = 0, .freq = 9173000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9175000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
|
@ -743,14 +698,9 @@ const LoRaWANBand_t KR920 = {
|
|||
.dwellTimeDn = 0,
|
||||
.txParamSupported = false,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 9221000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9223000, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 9225000, .drMin = 0, .drMax = 5, .dr = 5, .available = true }
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
{ .enabled = true, .idx = 0, .freq = 9221000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 9223000, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 9225000, .drMin = 0, .drMax = 5, .dr = 3, .available = true }
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
.txSpans = {
|
||||
|
@ -816,14 +766,9 @@ const LoRaWANBand_t IN865 = {
|
|||
.dwellTimeDn = 0,
|
||||
.txParamSupported = false,
|
||||
.txFreqs = {
|
||||
{ .enabled = true, .idx = 0, .freq = 8650625, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 8654025, .drMin = 0, .drMax = 5, .dr = 5, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 8659850, .drMin = 0, .drMax = 5, .dr = 5, .available = true }
|
||||
},
|
||||
.txJoinReq = {
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE,
|
||||
RADIOLIB_LORAWAN_CHANNEL_NONE
|
||||
{ .enabled = true, .idx = 0, .freq = 8650625, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 1, .freq = 8654025, .drMin = 0, .drMax = 5, .dr = 3, .available = true },
|
||||
{ .enabled = true, .idx = 2, .freq = 8659850, .drMin = 0, .drMax = 5, .dr = 3, .available = true }
|
||||
},
|
||||
.numTxSpans = 0,
|
||||
.txSpans = {
|
||||
|
|
Ładowanie…
Reference in New Issue