From fb75471e312b002f4ed63d5c90ae0032cbd658ff Mon Sep 17 00:00:00 2001 From: Brian Danilko Date: Sat, 14 Jul 2018 09:56:57 +0930 Subject: [PATCH] lib/lora: Fix manual add of channels 64-71 The LoRaWAN-Regional-Parameters document (1.02 and 1.1.), for AU915 and US915, lists the channels 64 - 71 as having specific data rates which are not zero. This change removes the check of dr_min == 0 for these channels when they are added manually. Also a simple sanity check is done for the dr range. --- lib/lora/mac/region/RegionAU915.c | 10 ++++++++-- lib/lora/mac/region/RegionUS915.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/lora/mac/region/RegionAU915.c b/lib/lora/mac/region/RegionAU915.c index 5e2486b51a..78e0abebbc 100644 --- a/lib/lora/mac/region/RegionAU915.c +++ b/lib/lora/mac/region/RegionAU915.c @@ -841,8 +841,8 @@ LoRaMacStatus_t RegionAU915ChannelManualAdd( ChannelAddParams_t* channelAdd ) return LORAMAC_STATUS_PARAMETER_INVALID; } - // Validate the datarate range for min: must be DR_0 - if( channelAdd->NewChannel->DrRange.Fields.Min != DR_0 ) + // Validate the datarate range for min: must be DR_0 for channels 0-63 + if( id < 64 && channelAdd->NewChannel->DrRange.Fields.Min != DR_0 ) { drInvalid = true; } @@ -852,6 +852,12 @@ LoRaMacStatus_t RegionAU915ChannelManualAdd( ChannelAddParams_t* channelAdd ) drInvalid = true; } + // Sanity check that Min is not greater then Max + if (channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max) + { + drInvalid = true; + } + // Check frequency if( ( channelAdd->NewChannel->Frequency < 915000000 ) || ( channelAdd->NewChannel->Frequency > 928000000 ) ) { diff --git a/lib/lora/mac/region/RegionUS915.c b/lib/lora/mac/region/RegionUS915.c index 09c232700a..54c904becc 100644 --- a/lib/lora/mac/region/RegionUS915.c +++ b/lib/lora/mac/region/RegionUS915.c @@ -849,8 +849,8 @@ LoRaMacStatus_t RegionUS915ChannelManualAdd( ChannelAddParams_t* channelAdd ) return LORAMAC_STATUS_PARAMETER_INVALID; } - // Validate the datarate range for min: must be DR_0 - if( channelAdd->NewChannel->DrRange.Fields.Min != DR_0 ) + // Validate the datarate range for min: must be DR_0 for channels 0-63 + if( id < 64 && channelAdd->NewChannel->DrRange.Fields.Min != DR_0 ) { drInvalid = true; } @@ -860,6 +860,12 @@ LoRaMacStatus_t RegionUS915ChannelManualAdd( ChannelAddParams_t* channelAdd ) drInvalid = true; } + // Sanity check that Min is not greater then Max + if (channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max) + { + drInvalid = true; + } + // Check frequency if( ( channelAdd->NewChannel->Frequency < 902000000 ) || ( channelAdd->NewChannel->Frequency > 928000000 ) ) {