Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 0ce93d4

Browse files
oligauciwahdan88
authored andcommitted
modlora: Fix for class C downlink data in ABP mode
1 parent ba178ae commit 0ce93d4

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

esp32/mods/modlora.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,10 @@ static void TASK_LoRa (void *pvParameters) {
967967
#if defined(FIPY) || defined(LOPY4)
968968
xSemaphoreTake(xLoRaSigfoxSem, portMAX_DELAY);
969969
#endif
970+
mibReq.Type = MIB_NETWORK_ACTIVATION;
971+
mibReq.Param.NetworkActivation = ACTIVATION_TYPE_OTAA;
972+
LoRaMacMibSetRequestConfirm( &mibReq );
973+
970974
TimerStart( &TxNextActReqTimer );
971975
mlmeReq.Type = MLME_JOIN;
972976
mlmeReq.Req.Join.DevEui = (uint8_t *)lora_obj.u.otaa.DevEui;
@@ -976,6 +980,10 @@ static void TASK_LoRa (void *pvParameters) {
976980
mlmeReq.Req.Join.DR = (uint8_t) lora_obj.otaa_dr;
977981
LoRaMacMlmeRequest( &mlmeReq );
978982
} else {
983+
mibReq.Type = MIB_NETWORK_ACTIVATION;
984+
mibReq.Param.NetworkActivation = ACTIVATION_TYPE_ABP;
985+
LoRaMacMibSetRequestConfirm( &mibReq );
986+
979987
mibReq.Type = MIB_NET_ID;
980988
mibReq.Param.NetID = lora_obj.net_id;
981989
LoRaMacMibSetRequestConfirm( &mibReq );

lib/lora/mac/LoRaMac.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ static MulticastParams_t *MulticastChannels = NULL;
120120
*/
121121
static DeviceClass_t LoRaMacDeviceClass;
122122

123+
/*
124+
* End-Device network activation
125+
*/
126+
static ActivationType_t NetworkActivation;
127+
123128
/*!
124129
* Indicates if the node is connected to a private or public network
125130
*/
@@ -1458,6 +1463,10 @@ static void OnRxWindow2TimerEvent( void )
14581463
else
14591464
{
14601465
RxWindow2Config.RxContinuous = true;
1466+
1467+
if (NetworkActivation == ACTIVATION_TYPE_ABP){
1468+
RxWindow2Config.Datarate = McpsIndication.RxDatarate;
1469+
}
14611470
}
14621471

14631472
if( RegionRxConfig( LoRaMacRegion, &RxWindow2Config, ( int8_t* )&McpsIndication.RxDatarate ) == true )
@@ -2301,6 +2310,7 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacC
23012310

23022311
LoRaMacDeviceClass = CLASS_A;
23032312
LoRaMacState = LORAMAC_IDLE;
2313+
NetworkActivation = ACTIVATION_TYPE_NONE;
23042314

23052315
JoinRequestTrials = 0;
23062316
MaxJoinRequestTrials = 1;
@@ -2501,6 +2511,11 @@ LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t *mibGet )
25012511
mibGet->Param.Class = LoRaMacDeviceClass;
25022512
break;
25032513
}
2514+
case MIB_NETWORK_ACTIVATION:
2515+
{
2516+
mibGet->Param.NetworkActivation = NetworkActivation;
2517+
break;
2518+
}
25042519
case MIB_NETWORK_JOINED:
25052520
{
25062521
mibGet->Param.IsNetworkJoined = IsLoRaMacNetworkJoined;
@@ -2705,6 +2720,18 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t *mibSet )
27052720
}
27062721
break;
27072722
}
2723+
case MIB_NETWORK_ACTIVATION:
2724+
{
2725+
if( mibSet->Param.NetworkActivation != ACTIVATION_TYPE_OTAA )
2726+
{
2727+
NetworkActivation = mibSet->Param.NetworkActivation;
2728+
}
2729+
else
2730+
{
2731+
status = LORAMAC_STATUS_PARAMETER_INVALID;
2732+
}
2733+
break;
2734+
}
27082735
case MIB_NETWORK_JOINED:
27092736
{
27102737
IsLoRaMacNetworkJoined = mibSet->Param.IsNetworkJoined;

lib/lora/mac/LoRaMac.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ typedef enum eDeviceClass
142142
CLASS_C,
143143
}DeviceClass_t;
144144

145+
/*!
146+
* End-Device activation type
147+
*/
148+
typedef enum eActivationType
149+
{
150+
/*!
151+
* None
152+
*/
153+
ACTIVATION_TYPE_NONE = 0,
154+
/*!
155+
* Activation By Personalization (ACTIVATION_TYPE_ABP)
156+
*/
157+
ACTIVATION_TYPE_ABP = 1,
158+
/*!
159+
* Over-The-Air Activation (ACTIVATION_TYPE_OTAA)
160+
*/
161+
ACTIVATION_TYPE_OTAA = 2,
162+
}ActivationType_t;
163+
145164
/*!
146165
* LoRaMAC channels parameters definition
147166
*/
@@ -1111,6 +1130,7 @@ typedef struct sMlmeConfirm
11111130
* Attribute | Get | Set
11121131
* --------------------------------- | :-: | :-:
11131132
* \ref MIB_DEVICE_CLASS | YES | YES
1133+
* \ref MIB_NETWORK_ACTIVATION | YES | YES
11141134
* \ref MIB_NETWORK_JOINED | YES | YES
11151135
* \ref MIB_ADR | YES | YES
11161136
* \ref MIB_NET_ID | YES | YES
@@ -1156,6 +1176,12 @@ typedef enum eMib
11561176
* LoRaWAN Specification V1.0.2
11571177
*/
11581178
MIB_DEVICE_CLASS,
1179+
/*!
1180+
* LoRaWAN Network End-Device Activation
1181+
*
1182+
* LoRaWAN Specification V1.0.2
1183+
*/
1184+
MIB_NETWORK_ACTIVATION,
11591185
/*!
11601186
* LoRaWAN Network joined attribute
11611187
*
@@ -1359,6 +1385,12 @@ typedef union uMibParam
13591385
* Related MIB type: \ref MIB_DEVICE_CLASS
13601386
*/
13611387
DeviceClass_t Class;
1388+
/*!
1389+
* LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP or OTTA )
1390+
*
1391+
* Related MIB type: \ref MIB_NETWORK_ACTIVATION
1392+
*/
1393+
ActivationType_t NetworkActivation;
13621394
/*!
13631395
* LoRaWAN network joined attribute
13641396
*

0 commit comments

Comments
 (0)