Skip to content

Commit 6921e1c

Browse files
committed
Fix OnMacProcessNotify handling.
#510
1 parent d5e7a9b commit 6921e1c

File tree

12 files changed

+180
-180
lines changed

12 files changed

+180
-180
lines changed

src/apps/LoRaMac/classA/NAMote72/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ static TimerEvent_t Led2Timer;
164164
static bool NextTx = true;
165165

166166
/*!
167-
* Indicates if LoRaMacProcess must be called.
167+
* Indicates if LoRaMacProcess call is pending.
168168
*
169169
* \warning If variable is equal to 0 then the MCU can be set in low power mode
170170
*/
171-
static uint8_t IsMacProcessRequired = 0;
171+
static uint8_t IsMacProcessPending = 0;
172172

173173
/*!
174174
* Device states
@@ -998,7 +998,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
998998

999999
void OnMacProcessNotify( void )
10001000
{
1001-
IsMacProcessRequired = 1;
1001+
IsMacProcessPending = 1;
10021002
}
10031003

10041004
/**
@@ -1036,15 +1036,8 @@ int main( void )
10361036
{
10371037
Radio.IrqProcess( );
10381038
}
1039-
if( IsMacProcessRequired == 1 )
1040-
{
1041-
CRITICAL_SECTION_BEGIN( );
1042-
IsMacProcessRequired = 0;
1043-
CRITICAL_SECTION_END( );
1044-
1045-
// Processes the LoRaMac events
1046-
LoRaMacProcess( );
1047-
}
1039+
// Processes the LoRaMac events
1040+
LoRaMacProcess( );
10481041

10491042
switch( DeviceState )
10501043
{
@@ -1247,11 +1240,18 @@ int main( void )
12471240
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
12481241
}
12491242

1250-
if( IsMacProcessRequired == 0 )
1243+
CRITICAL_SECTION_BEGIN( );
1244+
if( IsMacProcessPending == 1 )
12511245
{
1252-
// Wake up through events
1246+
// Clear flag and prevent MCU to go into low power modes.
1247+
IsMacProcessPending = 0;
1248+
}
1249+
else
1250+
{
1251+
// The MCU wakes up through events
12531252
BoardLowPowerHandler( );
1254-
}
1253+
}
1254+
CRITICAL_SECTION_END( );
12551255
break;
12561256
}
12571257
default:

src/apps/LoRaMac/classA/NucleoL073/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ static TimerEvent_t Led2Timer;
161161
static bool NextTx = true;
162162

163163
/*!
164-
* Indicates if LoRaMacProcess must be called.
164+
* Indicates if LoRaMacProcess call is pending.
165165
*
166166
* \warning If variable is equal to 0 then the MCU can be set in low power mode
167167
*/
168-
static uint8_t IsMacProcessRequired = 0;
168+
static uint8_t IsMacProcessPending = 0;
169169

170170
/*!
171171
* Device states
@@ -903,7 +903,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
903903

904904
void OnMacProcessNotify( void )
905905
{
906-
IsMacProcessRequired = 1;
906+
IsMacProcessPending = 1;
907907
}
908908

909909
/**
@@ -941,15 +941,8 @@ int main( void )
941941
{
942942
Radio.IrqProcess( );
943943
}
944-
if( IsMacProcessRequired == 1 )
945-
{
946-
CRITICAL_SECTION_BEGIN( );
947-
IsMacProcessRequired = 0;
948-
CRITICAL_SECTION_END( );
949-
950-
// Processes the LoRaMac events
951-
LoRaMacProcess( );
952-
}
944+
// Processes the LoRaMac events
945+
LoRaMacProcess( );
953946

954947
switch( DeviceState )
955948
{
@@ -1152,11 +1145,18 @@ int main( void )
11521145
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
11531146
}
11541147

1155-
if( IsMacProcessRequired == 0 )
1148+
CRITICAL_SECTION_BEGIN( );
1149+
if( IsMacProcessPending == 1 )
11561150
{
1157-
// Wake up through events
1151+
// Clear flag and prevent MCU to go into low power modes.
1152+
IsMacProcessPending = 0;
1153+
}
1154+
else
1155+
{
1156+
// The MCU wakes up through events
11581157
BoardLowPowerHandler( );
1159-
}
1158+
}
1159+
CRITICAL_SECTION_END( );
11601160
break;
11611161
}
11621162
default:

src/apps/LoRaMac/classA/NucleoL152/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ static TimerEvent_t Led2Timer;
161161
static bool NextTx = true;
162162

163163
/*!
164-
* Indicates if LoRaMacProcess must be called.
164+
* Indicates if LoRaMacProcess call is pending.
165165
*
166166
* \warning If variable is equal to 0 then the MCU can be set in low power mode
167167
*/
168-
static uint8_t IsMacProcessRequired = 0;
168+
static uint8_t IsMacProcessPending = 0;
169169

170170
/*!
171171
* Device states
@@ -903,7 +903,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
903903

904904
void OnMacProcessNotify( void )
905905
{
906-
IsMacProcessRequired = 1;
906+
IsMacProcessPending = 1;
907907
}
908908

909909
/**
@@ -941,15 +941,8 @@ int main( void )
941941
{
942942
Radio.IrqProcess( );
943943
}
944-
if( IsMacProcessRequired == 1 )
945-
{
946-
CRITICAL_SECTION_BEGIN( );
947-
IsMacProcessRequired = 0;
948-
CRITICAL_SECTION_END( );
949-
950-
// Processes the LoRaMac events
951-
LoRaMacProcess( );
952-
}
944+
// Processes the LoRaMac events
945+
LoRaMacProcess( );
953946

954947
switch( DeviceState )
955948
{
@@ -1152,11 +1145,18 @@ int main( void )
11521145
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
11531146
}
11541147

1155-
if( IsMacProcessRequired == 0 )
1148+
CRITICAL_SECTION_BEGIN( );
1149+
if( IsMacProcessPending == 1 )
11561150
{
1157-
// Wake up through events
1151+
// Clear flag and prevent MCU to go into low power modes.
1152+
IsMacProcessPending = 0;
1153+
}
1154+
else
1155+
{
1156+
// The MCU wakes up through events
11581157
BoardLowPowerHandler( );
1159-
}
1158+
}
1159+
CRITICAL_SECTION_END( );
11601160
break;
11611161
}
11621162
default:

src/apps/LoRaMac/classA/SAML21/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ static TimerEvent_t Led2Timer;
168168
static bool NextTx = true;
169169

170170
/*!
171-
* Indicates if LoRaMacProcess must be called.
171+
* Indicates if LoRaMacProcess call is pending.
172172
*
173173
* \warning If variable is equal to 0 then the MCU can be set in low power mode
174174
*/
175-
static uint8_t IsMacProcessRequired = 0;
175+
static uint8_t IsMacProcessPending = 0;
176176

177177
/*!
178178
* Device states
@@ -909,7 +909,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
909909

910910
void OnMacProcessNotify( void )
911911
{
912-
IsMacProcessRequired = 1;
912+
IsMacProcessPending = 1;
913913
}
914914

915915
/**
@@ -949,15 +949,8 @@ int main( void )
949949
{
950950
Radio.IrqProcess( );
951951
}
952-
if( IsMacProcessRequired == 1 )
953-
{
954-
CRITICAL_SECTION_BEGIN( );
955-
IsMacProcessRequired = 0;
956-
CRITICAL_SECTION_END( );
957-
958-
// Processes the LoRaMac events
959-
LoRaMacProcess( );
960-
}
952+
// Processes the LoRaMac events
953+
LoRaMacProcess( );
961954

962955
switch( DeviceState )
963956
{
@@ -1171,11 +1164,18 @@ int main( void )
11711164
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
11721165
}
11731166

1174-
if( IsMacProcessRequired == 0 )
1167+
CRITICAL_SECTION_BEGIN( );
1168+
if( IsMacProcessPending == 1 )
11751169
{
1176-
// Wake up through events
1170+
// Clear flag and prevent MCU to go into low power modes.
1171+
IsMacProcessPending = 0;
1172+
}
1173+
else
1174+
{
1175+
// The MCU wakes up through events
11771176
BoardLowPowerHandler( );
1178-
}
1177+
}
1178+
CRITICAL_SECTION_END( );
11791179
break;
11801180
}
11811181
default:

src/apps/LoRaMac/classB/NAMote72/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ static TimerEvent_t LedBeaconTimer;
182182
static bool NextTx = true;
183183

184184
/*!
185-
* Indicates if LoRaMacProcess must be called.
185+
* Indicates if LoRaMacProcess call is pending.
186186
*
187187
* \warning If variable is equal to 0 then the MCU can be set in low power mode
188188
*/
189-
static uint8_t IsMacProcessRequired = 0;
189+
static uint8_t IsMacProcessPending = 0;
190190

191191
/*!
192192
* Device states
@@ -1197,7 +1197,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
11971197

11981198
void OnMacProcessNotify( void )
11991199
{
1200-
IsMacProcessRequired = 1;
1200+
IsMacProcessPending = 1;
12011201
}
12021202

12031203
/**
@@ -1236,15 +1236,8 @@ int main( void )
12361236
{
12371237
Radio.IrqProcess( );
12381238
}
1239-
if( IsMacProcessRequired == 1 )
1240-
{
1241-
CRITICAL_SECTION_BEGIN( );
1242-
IsMacProcessRequired = 0;
1243-
CRITICAL_SECTION_END( );
1244-
1245-
// Processes the LoRaMac events
1246-
LoRaMacProcess( );
1247-
}
1239+
// Processes the LoRaMac events
1240+
LoRaMacProcess( );
12481241

12491242
switch( DeviceState )
12501243
{
@@ -1521,11 +1514,18 @@ int main( void )
15211514
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
15221515
}
15231516

1524-
if( IsMacProcessRequired == 0 )
1517+
CRITICAL_SECTION_BEGIN( );
1518+
if( IsMacProcessPending == 1 )
15251519
{
1526-
// Wake up through events
1520+
// Clear flag and prevent MCU to go into low power modes.
1521+
IsMacProcessPending = 0;
1522+
}
1523+
else
1524+
{
1525+
// The MCU wakes up through events
15271526
BoardLowPowerHandler( );
1528-
}
1527+
}
1528+
CRITICAL_SECTION_END( );
15291529
break;
15301530
}
15311531
default:

src/apps/LoRaMac/classB/NucleoL073/main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ static TimerEvent_t LedBeaconTimer;
179179
static bool NextTx = true;
180180

181181
/*!
182-
* Indicates if LoRaMacProcess must be called.
182+
* Indicates if LoRaMacProcess call is pending.
183183
*
184184
* \warning If variable is equal to 0 then the MCU can be set in low power mode
185185
*/
186-
static uint8_t IsMacProcessRequired = 0;
186+
static uint8_t IsMacProcessPending = 0;
187187

188188
/*!
189189
* Device states
@@ -1102,7 +1102,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
11021102

11031103
void OnMacProcessNotify( void )
11041104
{
1105-
IsMacProcessRequired = 1;
1105+
IsMacProcessPending = 1;
11061106
}
11071107

11081108
/**
@@ -1141,15 +1141,8 @@ int main( void )
11411141
{
11421142
Radio.IrqProcess( );
11431143
}
1144-
if( IsMacProcessRequired == 1 )
1145-
{
1146-
CRITICAL_SECTION_BEGIN( );
1147-
IsMacProcessRequired = 0;
1148-
CRITICAL_SECTION_END( );
1149-
1150-
// Processes the LoRaMac events
1151-
LoRaMacProcess( );
1152-
}
1144+
// Processes the LoRaMac events
1145+
LoRaMacProcess( );
11531146

11541147
switch( DeviceState )
11551148
{
@@ -1426,11 +1419,18 @@ int main( void )
14261419
printf( "\r\n###### ===== CTXS STORED ==== ######\r\n" );
14271420
}
14281421

1429-
if( IsMacProcessRequired == 0 )
1422+
CRITICAL_SECTION_BEGIN( );
1423+
if( IsMacProcessPending == 1 )
14301424
{
1431-
// Wake up through events
1425+
// Clear flag and prevent MCU to go into low power modes.
1426+
IsMacProcessPending = 0;
1427+
}
1428+
else
1429+
{
1430+
// The MCU wakes up through events
14321431
BoardLowPowerHandler( );
1433-
}
1432+
}
1433+
CRITICAL_SECTION_END( );
14341434
break;
14351435
}
14361436
default:

0 commit comments

Comments
 (0)