Skip to content

Commit 9d0263b

Browse files
committed
Changed NewChannelReq and DlChannelReq handling to ignore command for AU915, CN470 and US915 regions
1 parent 9b72434 commit 9d0263b

23 files changed

+83
-65
lines changed

src/mac/LoRaMac.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,13 +2155,16 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
21552155
chParam.Rx1Frequency = 0;
21562156
chParam.DrRange.Value = payload[macIndex++];
21572157

2158-
status = RegionNewChannelReq( MacCtx.NvmCtx->Region, &newChannelReq );
2158+
status = ( uint8_t )RegionNewChannelReq( MacCtx.NvmCtx->Region, &newChannelReq );
21592159

2160-
macCmdPayload[0] = status;
2161-
LoRaMacCommandsAddCmd( MOTE_MAC_NEW_CHANNEL_ANS, macCmdPayload, 1 );
2162-
if( status == 0x03 )
2160+
if( ( int8_t )status >= 0 )
21632161
{
2164-
EventRegionNvmCtxChanged( );
2162+
macCmdPayload[0] = status;
2163+
LoRaMacCommandsAddCmd( MOTE_MAC_NEW_CHANNEL_ANS, macCmdPayload, 1 );
2164+
if( status == 0x03 )
2165+
{
2166+
EventRegionNvmCtxChanged( );
2167+
}
21652168
}
21662169
break;
21672170
}
@@ -2231,14 +2234,18 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
22312234
dlChannelReq.Rx1Frequency |= ( uint32_t ) payload[macIndex++] << 16;
22322235
dlChannelReq.Rx1Frequency *= 100;
22332236

2234-
status = RegionDlChannelReq( MacCtx.NvmCtx->Region, &dlChannelReq );
2235-
macCmdPayload[0] = status;
2236-
LoRaMacCommandsAddCmd( MOTE_MAC_DL_CHANNEL_ANS, macCmdPayload, 1 );
2237-
// Setup indication to inform the application
2238-
SetMlmeScheduleUplinkIndication( );
2239-
if( status == 0x03 )
2237+
status = ( uint8_t )RegionDlChannelReq( MacCtx.NvmCtx->Region, &dlChannelReq );
2238+
2239+
if( ( int8_t )status >= 0 )
22402240
{
2241-
EventRegionNvmCtxChanged( );
2241+
macCmdPayload[0] = status;
2242+
LoRaMacCommandsAddCmd( MOTE_MAC_DL_CHANNEL_ANS, macCmdPayload, 1 );
2243+
// Setup indication to inform the application
2244+
SetMlmeScheduleUplinkIndication( );
2245+
if( status == 0x03 )
2246+
{
2247+
EventRegionNvmCtxChanged( );
2248+
}
22422249
}
22432250
break;
22442251
}

src/mac/region/Region.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t*
805805
}
806806
}
807807

808-
uint8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq )
808+
int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq )
809809
{
810810
switch( region )
811811
{
@@ -847,7 +847,7 @@ int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* t
847847
}
848848
}
849849

850-
uint8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq )
850+
int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq )
851851
{
852852
switch( region )
853853
{

src/mac/region/Region.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t*
15701570
*
15711571
* \retval Returns the status of the operation, according to the LoRaMAC specification.
15721572
*/
1573-
uint8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq );
1573+
int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq );
15741574

15751575
/*!
15761576
* \brief The function processes a TX ParamSetup Request.
@@ -1594,7 +1594,7 @@ int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* t
15941594
*
15951595
* \retval Returns the status of the operation, according to the LoRaMAC specification.
15961596
*/
1597-
uint8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq );
1597+
int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq );
15981598

15991599
/*!
16001600
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionAS923.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
805805
return status;
806806
}
807807

808-
uint8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq )
808+
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq )
809809
{
810810
uint8_t status = 0x03;
811811
ChannelAddParams_t channelAdd;
@@ -864,7 +864,7 @@ int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
864864
return 0;
865865
}
866866

867-
uint8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq )
867+
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq )
868868
{
869869
uint8_t status = 0x03;
870870

src/mac/region/RegionAS923.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
454454
*
455455
* \retval Returns the status of the operation, according to the LoRaMAC specification.
456456
*/
457-
uint8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq );
457+
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq );
458458

459459
/*!
460460
* \brief The function processes a TX ParamSetup Request.
@@ -474,7 +474,7 @@ int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
474474
*
475475
* \retval Returns the status of the operation, according to the LoRaMAC specification.
476476
*/
477-
uint8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq );
477+
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq );
478478

479479
/*!
480480
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionAU915.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,10 @@ uint8_t RegionAU915RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
798798
return status;
799799
}
800800

801-
uint8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq )
801+
int8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq )
802802
{
803-
// Datarate and frequency KO
804-
return 0;
803+
// Do not accept the request
804+
return -1;
805805
}
806806

807807
int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
@@ -810,9 +810,10 @@ int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
810810
return 0;
811811
}
812812

813-
uint8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq )
813+
int8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq )
814814
{
815-
return 0;
815+
// Do not accept the request
816+
return -1;
816817
}
817818

818819
int8_t RegionAU915AlternateDr( int8_t currentDr, AlternateDrType_t type )

src/mac/region/RegionAU915.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ uint8_t RegionAU915RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
379379
*
380380
* \retval Returns the status of the operation, according to the LoRaMAC specification.
381381
*/
382-
uint8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq );
382+
int8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq );
383383

384384
/*!
385385
* \brief The function processes a TX ParamSetup Request.
@@ -399,7 +399,7 @@ int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
399399
*
400400
* \retval Returns the status of the operation, according to the LoRaMAC specification.
401401
*/
402-
uint8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq );
402+
int8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq );
403403

404404
/*!
405405
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionCN470.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,20 +964,22 @@ uint8_t RegionCN470RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
964964
return status;
965965
}
966966

967-
uint8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq )
967+
int8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq )
968968
{
969-
// Datarate and frequency KO
970-
return 0;
969+
// Do not accept the request
970+
return -1;
971971
}
972972

973973
int8_t RegionCN470TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
974974
{
975+
// Do not accept the request
975976
return -1;
976977
}
977978

978-
uint8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq )
979+
int8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq )
979980
{
980-
return 0;
981+
// Do not accept the request
982+
return -1;
981983
}
982984

983985
int8_t RegionCN470AlternateDr( int8_t currentDr, AlternateDrType_t type )

src/mac/region/RegionCN470.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ uint8_t RegionCN470RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
376376
*
377377
* \retval Returns the status of the operation, according to the LoRaMAC specification.
378378
*/
379-
uint8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq );
379+
int8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq );
380380

381381
/*!
382382
* \brief The function processes a TX ParamSetup Request.
@@ -396,7 +396,7 @@ int8_t RegionCN470TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
396396
*
397397
* \retval Returns the status of the operation, according to the LoRaMAC specification.
398398
*/
399-
uint8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq );
399+
int8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq );
400400

401401
/*!
402402
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionCN779.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ uint8_t RegionCN779RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
707707
return status;
708708
}
709709

710-
uint8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
710+
int8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
711711
{
712712
uint8_t status = 0x03;
713713
ChannelAddParams_t channelAdd;
@@ -762,10 +762,11 @@ uint8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
762762

763763
int8_t RegionCN779TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
764764
{
765+
// Do not accept the request
765766
return -1;
766767
}
767768

768-
uint8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq )
769+
int8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq )
769770
{
770771
uint8_t status = 0x03;
771772

0 commit comments

Comments
 (0)