Skip to content

Commit 8402ca4

Browse files
authored
Make LBT RSSI free channel threshold and carrier sense time (CST) parameters configurable (#1344)
* Move RSSI threshold and carrier sense time to NVM To make it possible for the application to override the default values of these parameters, we need to move them to the RegionGroup2 section of the NVM. * Add MIB support for RSSI threshold and CST This patch makes it possible to get or set the RSSI free channel threshold and carrier sense time parameters in the KR920 and AS923 bands via the MIB.
1 parent 2fdce5f commit 8402ca4

7 files changed

Lines changed: 128 additions & 22 deletions

File tree

src/mac/LoRaMac.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,6 +4115,38 @@ LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t* mibGet )
41154115
mibGet->Param.Rejoin2CycleInSec = Nvm.MacGroup2.Rejoin2CycleInSec;
41164116
break;
41174117
}
4118+
case MIB_RSSI_FREE_THRESHOLD:
4119+
{
4120+
#if defined(REGION_KR920) || defined(REGION_AS923)
4121+
if( Nvm.MacGroup2.Region != LORAMAC_REGION_AS923 && Nvm.MacGroup2.Region != LORAMAC_REGION_KR920 )
4122+
{
4123+
status = LORAMAC_STATUS_ERROR;
4124+
}
4125+
else
4126+
{
4127+
mibGet->Param.RssiFreeThreshold = Nvm.RegionGroup2.RssiFreeThreshold;
4128+
}
4129+
#else
4130+
status = LORAMAC_STATUS_ERROR;
4131+
#endif
4132+
break;
4133+
}
4134+
case MIB_CARRIER_SENSE_TIME:
4135+
{
4136+
#if defined(REGION_KR920) || defined(REGION_AS923)
4137+
if( Nvm.MacGroup2.Region != LORAMAC_REGION_AS923 && Nvm.MacGroup2.Region != LORAMAC_REGION_KR920 )
4138+
{
4139+
status = LORAMAC_STATUS_ERROR;
4140+
}
4141+
else
4142+
{
4143+
mibGet->Param.CarrierSenseTime = Nvm.RegionGroup2.CarrierSenseTime;
4144+
}
4145+
#else
4146+
status = LORAMAC_STATUS_ERROR;
4147+
#endif
4148+
break;
4149+
}
41184150
default:
41194151
{
41204152
status = LoRaMacClassBMibGetRequestConfirm( mibGet );
@@ -4786,6 +4818,38 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet )
47864818
}
47874819
break;
47884820
}
4821+
case MIB_RSSI_FREE_THRESHOLD:
4822+
{
4823+
#if defined(REGION_KR920) || defined(REGION_AS923)
4824+
if( Nvm.MacGroup2.Region != LORAMAC_REGION_AS923 && Nvm.MacGroup2.Region != LORAMAC_REGION_KR920 )
4825+
{
4826+
status = LORAMAC_STATUS_ERROR;
4827+
}
4828+
else
4829+
{
4830+
Nvm.RegionGroup2.RssiFreeThreshold = mibSet->Param.RssiFreeThreshold;
4831+
}
4832+
#else
4833+
status = LORAMAC_STATUS_ERROR;
4834+
#endif
4835+
break;
4836+
}
4837+
case MIB_CARRIER_SENSE_TIME:
4838+
{
4839+
#if defined(REGION_KR920) || defined(REGION_AS923)
4840+
if( Nvm.MacGroup2.Region != LORAMAC_REGION_AS923 && Nvm.MacGroup2.Region != LORAMAC_REGION_KR920 )
4841+
{
4842+
status = LORAMAC_STATUS_ERROR;
4843+
}
4844+
else
4845+
{
4846+
Nvm.RegionGroup2.CarrierSenseTime = mibSet->Param.CarrierSenseTime;
4847+
}
4848+
#else
4849+
status = LORAMAC_STATUS_ERROR;
4850+
#endif
4851+
break;
4852+
}
47894853
default:
47904854
{
47914855
status = LoRaMacMibClassBSetRequestConfirm( mibSet );

src/mac/LoRaMac.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,8 @@ typedef struct sMlmeIndication
14371437
* \ref MIB_REJOIN_0_CYCLE | YES | YES
14381438
* \ref MIB_REJOIN_1_CYCLE | YES | YES
14391439
* \ref MIB_REJOIN_2_CYCLE | YES | NO
1440+
* \ref MIB_RSSI_FREE_THRESHOLD | YES | YES
1441+
* \ref MIB_CARRIER_SENSE_TIME | YES | YES
14401442
*
14411443
* The following table provides links to the function implementations of the
14421444
* related MIB primitives:
@@ -1869,6 +1871,14 @@ typedef enum eMib
18691871
* LoRaWAN certification FPort handling state (ON/OFF)
18701872
*/
18711873
MIB_IS_CERT_FPORT_ON,
1874+
/*!
1875+
* RSSI free channel threshold value (KR920 and AS923 only)
1876+
*/
1877+
MIB_RSSI_FREE_THRESHOLD,
1878+
/*!
1879+
* Carrier sense time value (KR920 and AS923 only)
1880+
*/
1881+
MIB_CARRIER_SENSE_TIME
18721882
}Mib_t;
18731883

18741884
/*!
@@ -2315,6 +2325,18 @@ typedef union uMibParam
23152325
* Related MIB type: \ref MIB_IS_CERT_FPORT_ON
23162326
*/
23172327
bool IsCertPortOn;
2328+
/*!
2329+
* RSSI free channel threshold (KR920 and AS923 only)
2330+
*
2331+
* Related MIB type: \ref MIB_RSSI_FREE_THRESHOLD
2332+
*/
2333+
int16_t RssiFreeThreshold;
2334+
/*!
2335+
* Carrier sense time (KR920 and AS923 only)
2336+
*
2337+
* Related MIB type: \ref MIB_CARRIER_SENSE_TIME
2338+
*/
2339+
uint32_t CarrierSenseTime;
23182340
}MibParam_t;
23192341

23202342
/*!

src/mac/region/RegionAS923.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
// Definitions
3636
#define CHANNELS_MASK_SIZE 1
3737

38+
/*!
39+
* RSSI threshold for a free channel [dBm]
40+
*/
41+
#define AS923_RSSI_FREE_TH -80
42+
43+
/*!
44+
* Specifies the time the node performs a carrier sense
45+
*/
46+
#define AS923_CARRIER_SENSE_TIME 5
47+
3848
#ifndef REGION_AS923_DEFAULT_CHANNEL_PLAN
3949
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1
4050
#endif
@@ -404,6 +414,11 @@ void RegionAS923InitDefaults( InitDefaultsParams_t* params )
404414

405415
// Update the channels mask
406416
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE );
417+
418+
#if ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP )
419+
RegionNvmGroup2->RssiFreeThreshold = AS923_RSSI_FREE_TH;
420+
RegionNvmGroup2->CarrierSenseTime = AS923_CARRIER_SENSE_TIME;
421+
#endif
407422
break;
408423
}
409424
case INIT_TYPE_RESET_TO_DEFAULT_CHANNELS:
@@ -933,7 +948,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_
933948

934949
// Perform carrier sense for AS923_CARRIER_SENSE_TIME
935950
// If the channel is free, we can stop the LBT mechanism
936-
if( Radio.IsChannelFree( RegionNvmGroup2->Channels[channelNext].Frequency, AS923_LBT_RX_BANDWIDTH, AS923_RSSI_FREE_TH, AS923_CARRIER_SENSE_TIME ) == true )
951+
if( Radio.IsChannelFree( RegionNvmGroup2->Channels[channelNext].Frequency, AS923_LBT_RX_BANDWIDTH, RegionNvmGroup2->RssiFreeThreshold, RegionNvmGroup2->CarrierSenseTime ) == true )
937952
{
938953
// Free channel found
939954
*channel = channelNext;

src/mac/region/RegionAS923.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ extern "C"
256256
*/
257257
#define AS923_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) )
258258

259-
/*!
260-
* RSSI threshold for a free channel [dBm]
261-
*/
262-
#define AS923_RSSI_FREE_TH -80
263-
264-
/*!
265-
* Specifies the time the node performs a carrier sense
266-
*/
267-
#define AS923_CARRIER_SENSE_TIME 5
268-
269259
/*!
270260
* Data rates table definition
271261
*/

src/mac/region/RegionKR920.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
*/
4242
#define KR920_LBT_RX_BANDWIDTH 200000
4343

44+
/*!
45+
* RSSI threshold for a free channel [dBm]
46+
*/
47+
#define KR920_RSSI_FREE_TH -65
48+
49+
/*!
50+
* Specifies the time the node performs a carrier sense
51+
*/
52+
#define KR920_CARRIER_SENSE_TIME 6
53+
4454
/*
4555
* Non-volatile module context.
4656
*/
@@ -330,6 +340,9 @@ void RegionKR920InitDefaults( InitDefaultsParams_t* params )
330340

331341
// Update the channels mask
332342
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE );
343+
344+
RegionNvmGroup2->RssiFreeThreshold = KR920_RSSI_FREE_TH;
345+
RegionNvmGroup2->CarrierSenseTime = KR920_CARRIER_SENSE_TIME;
333346
break;
334347
}
335348
case INIT_TYPE_RESET_TO_DEFAULT_CHANNELS:
@@ -818,7 +831,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_
818831

819832
// Perform carrier sense for KR920_CARRIER_SENSE_TIME
820833
// If the channel is free, we can stop the LBT mechanism
821-
if( Radio.IsChannelFree( RegionNvmGroup2->Channels[channelNext].Frequency, KR920_LBT_RX_BANDWIDTH, KR920_RSSI_FREE_TH, KR920_CARRIER_SENSE_TIME ) == true )
834+
if( Radio.IsChannelFree( RegionNvmGroup2->Channels[channelNext].Frequency, KR920_LBT_RX_BANDWIDTH, RegionNvmGroup2->RssiFreeThreshold, RegionNvmGroup2->CarrierSenseTime ) == true )
822835
{
823836
// Free channel found
824837
*channel = channelNext;

src/mac/region/RegionKR920.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,6 @@ extern "C"
230230
*/
231231
#define KR920_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
232232

233-
/*!
234-
* RSSI threshold for a free channel [dBm]
235-
*/
236-
#define KR920_RSSI_FREE_TH -65
237-
238-
/*!
239-
* Specifies the time the node performs a carrier sense
240-
*/
241-
#define KR920_CARRIER_SENSE_TIME 6
242-
243233
/*!
244234
* Data rates table definition
245235
*/

src/mac/region/RegionNvm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ typedef struct sRegionNvmDataGroup2
141141
*/
142142
bool IsOtaaDevice;
143143
#endif
144+
#if defined( REGION_KR920 ) || defined( REGION_AS923 )
145+
/*!
146+
* RSSI threshold for a free channel [dBm]
147+
*/
148+
int16_t RssiFreeThreshold;
149+
150+
/*!
151+
* Specifies the time the node performs a carrier sense
152+
*/
153+
uint32_t CarrierSenseTime;
154+
#endif
155+
144156
/*!
145157
* CRC32 value of the Region data structure.
146158
*/

0 commit comments

Comments
 (0)