Skip to content

Commit acbb99f

Browse files
committed
Changed NewChannelReq and DlChannelReq handling to ignore command for AU915, CN470 and US915 regions
1 parent 1852d89 commit acbb99f

23 files changed

+80
-65
lines changed

src/mac/LoRaMac.c

+19-12
Original file line numberDiff line numberDiff line change
@@ -2076,13 +2076,16 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
20762076
chParam.Rx1Frequency = 0;
20772077
chParam.DrRange.Value = payload[macIndex++];
20782078

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

2081-
macCmdPayload[0] = status;
2082-
LoRaMacCommandsAddCmd( MOTE_MAC_NEW_CHANNEL_ANS, macCmdPayload, 1 );
2083-
if( status == 0x03 )
2081+
if( ( int8_t )status >= 0 )
20842082
{
2085-
EventRegionNvmCtxChanged( );
2083+
macCmdPayload[0] = status;
2084+
LoRaMacCommandsAddCmd( MOTE_MAC_NEW_CHANNEL_ANS, macCmdPayload, 1 );
2085+
if( status == 0x03 )
2086+
{
2087+
EventRegionNvmCtxChanged( );
2088+
}
20862089
}
20872090
break;
20882091
}
@@ -2152,14 +2155,18 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
21522155
dlChannelReq.Rx1Frequency |= ( uint32_t ) payload[macIndex++] << 16;
21532156
dlChannelReq.Rx1Frequency *= 100;
21542157

2155-
status = RegionDlChannelReq( MacCtx.NvmCtx->Region, &dlChannelReq );
2156-
macCmdPayload[0] = status;
2157-
LoRaMacCommandsAddCmd( MOTE_MAC_DL_CHANNEL_ANS, macCmdPayload, 1 );
2158-
// Setup indication to inform the application
2159-
SetMlmeScheduleUplinkIndication( );
2160-
if( status == 0x03 )
2158+
status = ( uint8_t )RegionDlChannelReq( MacCtx.NvmCtx->Region, &dlChannelReq );
2159+
2160+
if( ( int8_t )status >= 0 )
21612161
{
2162-
EventRegionNvmCtxChanged( );
2162+
macCmdPayload[0] = status;
2163+
LoRaMacCommandsAddCmd( MOTE_MAC_DL_CHANNEL_ANS, macCmdPayload, 1 );
2164+
// Setup indication to inform the application
2165+
SetMlmeScheduleUplinkIndication( );
2166+
if( status == 0x03 )
2167+
{
2168+
EventRegionNvmCtxChanged( );
2169+
}
21632170
}
21642171
break;
21652172
}

src/mac/region/Region.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t*
825825
}
826826
}
827827

828-
uint8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq )
828+
int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq )
829829
{
830830
switch( region )
831831
{
@@ -867,7 +867,7 @@ int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* t
867867
}
868868
}
869869

870-
uint8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq )
870+
int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq )
871871
{
872872
switch( region )
873873
{

src/mac/region/Region.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t*
15961596
*
15971597
* \retval Returns the status of the operation, according to the LoRaMAC specification.
15981598
*/
1599-
uint8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq );
1599+
int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq );
16001600

16011601
/*!
16021602
* \brief The function processes a TX ParamSetup Request.
@@ -1620,7 +1620,7 @@ int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* t
16201620
*
16211621
* \retval Returns the status of the operation, according to the LoRaMAC specification.
16221622
*/
1623-
uint8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq );
1623+
int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq );
16241624

16251625
/*!
16261626
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionAS923.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
810810
return status;
811811
}
812812

813-
uint8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq )
813+
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq )
814814
{
815815
uint8_t status = 0x03;
816816
ChannelAddParams_t channelAdd;
@@ -869,7 +869,7 @@ int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
869869
return 0;
870870
}
871871

872-
uint8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq )
872+
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq )
873873
{
874874
uint8_t status = 0x03;
875875

src/mac/region/RegionAS923.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
416416
*
417417
* \retval Returns the status of the operation, according to the LoRaMAC specification.
418418
*/
419-
uint8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq );
419+
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq );
420420

421421
/*!
422422
* \brief The function processes a TX ParamSetup Request.
@@ -436,7 +436,7 @@ int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
436436
*
437437
* \retval Returns the status of the operation, according to the LoRaMAC specification.
438438
*/
439-
uint8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq );
439+
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq );
440440

441441
/*!
442442
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionAU915.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,10 @@ uint8_t RegionAU915RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
803803
return status;
804804
}
805805

806-
uint8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq )
806+
int8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq )
807807
{
808-
// Datarate and frequency KO
809-
return 0;
808+
// Do not accept the request
809+
return -1;
810810
}
811811

812812
int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
@@ -815,9 +815,10 @@ int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
815815
return 0;
816816
}
817817

818-
uint8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq )
818+
int8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq )
819819
{
820-
return 0;
820+
// Do not accept the request
821+
return -1;
821822
}
822823

823824
int8_t RegionAU915AlternateDr( int8_t currentDr, AlternateDrType_t type )

src/mac/region/RegionAU915.h

+2-2
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

+6-5
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ uint8_t RegionCN470RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
650650
return status;
651651
}
652652

653-
uint8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq )
653+
int8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq )
654654
{
655-
// Datarate and frequency KO
656-
return 0;
655+
// Do not accept the request
656+
return -1;
657657
}
658658

659659
int8_t RegionCN470TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
@@ -662,9 +662,10 @@ int8_t RegionCN470TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
662662
return -1;
663663
}
664664

665-
uint8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq )
665+
int8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq )
666666
{
667-
return 0;
667+
// Do not accept the request
668+
return -1;
668669
}
669670

670671
int8_t RegionCN470AlternateDr( int8_t currentDr, AlternateDrType_t type )

src/mac/region/RegionCN470.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ uint8_t RegionCN470RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
352352
*
353353
* \retval Returns the status of the operation, according to the LoRaMAC specification.
354354
*/
355-
uint8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq );
355+
int8_t RegionCN470NewChannelReq( NewChannelReqParams_t* newChannelReq );
356356

357357
/*!
358358
* \brief The function processes a TX ParamSetup Request.
@@ -372,7 +372,7 @@ int8_t RegionCN470TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
372372
*
373373
* \retval Returns the status of the operation, according to the LoRaMAC specification.
374374
*/
375-
uint8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq );
375+
int8_t RegionCN470DlChannelReq( DlChannelReqParams_t* dlChannelReq );
376376

377377
/*!
378378
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionCN779.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ uint8_t RegionCN779RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
712712
return status;
713713
}
714714

715-
uint8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
715+
int8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
716716
{
717717
uint8_t status = 0x03;
718718
ChannelAddParams_t channelAdd;
@@ -767,10 +767,11 @@ uint8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq )
767767

768768
int8_t RegionCN779TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
769769
{
770+
// Do not accept the request
770771
return -1;
771772
}
772773

773-
uint8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq )
774+
int8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq )
774775
{
775776
uint8_t status = 0x03;
776777

src/mac/region/RegionCN779.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ uint8_t RegionCN779RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
366366
*
367367
* \retval Returns the status of the operation, according to the LoRaMAC specification.
368368
*/
369-
uint8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq );
369+
int8_t RegionCN779NewChannelReq( NewChannelReqParams_t* newChannelReq );
370370

371371
/*!
372372
* \brief The function processes a TX ParamSetup Request.
@@ -386,7 +386,7 @@ int8_t RegionCN779TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
386386
*
387387
* \retval Returns the status of the operation, according to the LoRaMAC specification.
388388
*/
389-
uint8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq );
389+
int8_t RegionCN779DlChannelReq( DlChannelReqParams_t* dlChannelReq );
390390

391391
/*!
392392
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionEU433.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ uint8_t RegionEU433RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
712712
return status;
713713
}
714714

715-
uint8_t RegionEU433NewChannelReq( NewChannelReqParams_t* newChannelReq )
715+
int8_t RegionEU433NewChannelReq( NewChannelReqParams_t* newChannelReq )
716716
{
717717
uint8_t status = 0x03;
718718
ChannelAddParams_t channelAdd;
@@ -767,10 +767,11 @@ uint8_t RegionEU433NewChannelReq( NewChannelReqParams_t* newChannelReq )
767767

768768
int8_t RegionEU433TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
769769
{
770+
// Do not accept the request
770771
return -1;
771772
}
772773

773-
uint8_t RegionEU433DlChannelReq( DlChannelReqParams_t* dlChannelReq )
774+
int8_t RegionEU433DlChannelReq( DlChannelReqParams_t* dlChannelReq )
774775
{
775776
uint8_t status = 0x03;
776777

src/mac/region/RegionEU433.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ uint8_t RegionEU433RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
367367
*
368368
* \retval Returns the status of the operation, according to the LoRaMAC specification.
369369
*/
370-
uint8_t RegionEU433NewChannelReq( NewChannelReqParams_t* newChannelReq );
370+
int8_t RegionEU433NewChannelReq( NewChannelReqParams_t* newChannelReq );
371371

372372
/*!
373373
* \brief The function processes a TX ParamSetup Request.
@@ -387,7 +387,7 @@ int8_t RegionEU433TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
387387
*
388388
* \retval Returns the status of the operation, according to the LoRaMAC specification.
389389
*/
390-
uint8_t RegionEU433DlChannelReq( DlChannelReqParams_t* dlChannelReq );
390+
int8_t RegionEU433DlChannelReq( DlChannelReqParams_t* dlChannelReq );
391391

392392
/*!
393393
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionEU868.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ uint8_t RegionEU868RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
744744
return status;
745745
}
746746

747-
uint8_t RegionEU868NewChannelReq( NewChannelReqParams_t* newChannelReq )
747+
int8_t RegionEU868NewChannelReq( NewChannelReqParams_t* newChannelReq )
748748
{
749749
uint8_t status = 0x03;
750750
ChannelAddParams_t channelAdd;
@@ -803,7 +803,7 @@ int8_t RegionEU868TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
803803
return -1;
804804
}
805805

806-
uint8_t RegionEU868DlChannelReq( DlChannelReqParams_t* dlChannelReq )
806+
int8_t RegionEU868DlChannelReq( DlChannelReqParams_t* dlChannelReq )
807807
{
808808
uint8_t status = 0x03;
809809
uint8_t band = 0;

src/mac/region/RegionEU868.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ uint8_t RegionEU868RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
395395
*
396396
* \retval Returns the status of the operation, according to the LoRaMAC specification.
397397
*/
398-
uint8_t RegionEU868NewChannelReq( NewChannelReqParams_t* newChannelReq );
398+
int8_t RegionEU868NewChannelReq( NewChannelReqParams_t* newChannelReq );
399399

400400
/*!
401401
* \brief The function processes a TX ParamSetup Request.
@@ -415,7 +415,7 @@ int8_t RegionEU868TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
415415
*
416416
* \retval Returns the status of the operation, according to the LoRaMAC specification.
417417
*/
418-
uint8_t RegionEU868DlChannelReq( DlChannelReqParams_t* dlChannelReq );
418+
int8_t RegionEU868DlChannelReq( DlChannelReqParams_t* dlChannelReq );
419419

420420
/*!
421421
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionIN865.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ uint8_t RegionIN865RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
734734
return status;
735735
}
736736

737-
uint8_t RegionIN865NewChannelReq( NewChannelReqParams_t* newChannelReq )
737+
int8_t RegionIN865NewChannelReq( NewChannelReqParams_t* newChannelReq )
738738
{
739739
uint8_t status = 0x03;
740740
ChannelAddParams_t channelAdd;
@@ -789,10 +789,11 @@ uint8_t RegionIN865NewChannelReq( NewChannelReqParams_t* newChannelReq )
789789

790790
int8_t RegionIN865TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
791791
{
792+
// Do not accept the request
792793
return -1;
793794
}
794795

795-
uint8_t RegionIN865DlChannelReq( DlChannelReqParams_t* dlChannelReq )
796+
int8_t RegionIN865DlChannelReq( DlChannelReqParams_t* dlChannelReq )
796797
{
797798
uint8_t status = 0x03;
798799

src/mac/region/RegionIN865.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ uint8_t RegionIN865RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
369369
*
370370
* \retval Returns the status of the operation, according to the LoRaMAC specification.
371371
*/
372-
uint8_t RegionIN865NewChannelReq( NewChannelReqParams_t* newChannelReq );
372+
int8_t RegionIN865NewChannelReq( NewChannelReqParams_t* newChannelReq );
373373

374374
/*!
375375
* \brief The function processes a TX ParamSetup Request.
@@ -389,7 +389,7 @@ int8_t RegionIN865TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
389389
*
390390
* \retval Returns the status of the operation, according to the LoRaMAC specification.
391391
*/
392-
uint8_t RegionIN865DlChannelReq( DlChannelReqParams_t* dlChannelReq );
392+
int8_t RegionIN865DlChannelReq( DlChannelReqParams_t* dlChannelReq );
393393

394394
/*!
395395
* \brief Alternates the datarate of the channel for the join request.

src/mac/region/RegionKR920.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ uint8_t RegionKR920RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
708708
return status;
709709
}
710710

711-
uint8_t RegionKR920NewChannelReq( NewChannelReqParams_t* newChannelReq )
711+
int8_t RegionKR920NewChannelReq( NewChannelReqParams_t* newChannelReq )
712712
{
713713
uint8_t status = 0x03;
714714
ChannelAddParams_t channelAdd;
@@ -763,10 +763,11 @@ uint8_t RegionKR920NewChannelReq( NewChannelReqParams_t* newChannelReq )
763763

764764
int8_t RegionKR920TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
765765
{
766+
// Do not accept the request
766767
return -1;
767768
}
768769

769-
uint8_t RegionKR920DlChannelReq( DlChannelReqParams_t* dlChannelReq )
770+
int8_t RegionKR920DlChannelReq( DlChannelReqParams_t* dlChannelReq )
770771
{
771772
uint8_t status = 0x03;
772773

0 commit comments

Comments
 (0)