Skip to content

Commit de25cb7

Browse files
authored
Fixes for class C activation and deactivation (#1325)
* Deactivate radio on a switch from class C to A When the MAC switches from class C to class A, we must update one of the internal state variables to make sure that the radio is not put into the continuous RX mode again in LoRaMacProcess. * Reactivate radio for continuous RX when starting in class C * Put radio to sleep in LoRaMacStop if in class C If the MAC is operating in class C and the application invokes LoRaMacStop, make sure the radio will not remain receiving continuously, draining batteries. LoRaMacStart will switch the radio into a continuous RX mode again.
1 parent ff9dfea commit de25cb7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mac/LoRaMac.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,9 @@ static LoRaMacStatus_t SwitchClass( DeviceClass_t deviceClass )
20182018
{
20192019
if( deviceClass == CLASS_A )
20202020
{
2021+
// Reset RxSlot to NONE
2022+
MacCtx.RxSlot = RX_SLOT_NONE;
2023+
20212024
Nvm.MacGroup2.DeviceClass = deviceClass;
20222025

20232026
// Set the radio into sleep to setup a defined state
@@ -3827,13 +3830,18 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC
38273830
LoRaMacStatus_t LoRaMacStart( void )
38283831
{
38293832
MacCtx.MacState = LORAMAC_IDLE;
3833+
UpdateRxSlotIdleState();
38303834
return LORAMAC_STATUS_OK;
38313835
}
38323836

38333837
LoRaMacStatus_t LoRaMacStop( void )
38343838
{
38353839
if( LoRaMacIsBusy( ) == false )
38363840
{
3841+
if( Nvm.MacGroup2.DeviceClass == CLASS_C )
3842+
{
3843+
Radio.Sleep( );
3844+
}
38373845
MacCtx.MacState = LORAMAC_STOPPED;
38383846
return LORAMAC_STATUS_OK;
38393847
}

0 commit comments

Comments
 (0)