Skip to content

Commit f0c08bb

Browse files
committed
Changed improved the way LmHanler handles the packages transmissions
Avoids conflicts between normal application uplinks and packages uplinks
1 parent dbe393e commit f0c08bb

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

src/apps/LoRaMac/common/LmHandler/LmHandler.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ typedef enum PackageNotifyTypes_e
225225
*/
226226
static void LmHandlerPackagesNotify( PackageNotifyTypes_t notifyType, void *params );
227227

228+
static bool LmHandlerPackageIsTxPending( void );
229+
228230
static void LmHandlerPackagesProcess( void );
229231

230232
LmHandlerErrorStatus_t LmHandlerInit( LmHandlerCallbacks_t *handlerCallbacks,
@@ -344,15 +346,9 @@ bool LmHandlerIsBusy( void )
344346
return true;
345347
}
346348

347-
for( int8_t i = 0; i < PKG_MAX_NUMBER; i++ )
349+
if( LmHandlerPackageIsTxPending( ) == true )
348350
{
349-
if( LmHandlerPackages[i] != NULL )
350-
{
351-
if( LmHandlerPackages[i]->IsTxPending( ) == true )
352-
{
353-
return true;
354-
}
355-
}
351+
return true;
356352
}
357353

358354
return false;
@@ -382,6 +378,13 @@ void LmHandlerProcess( void )
382378
// Call all packages process functions
383379
LmHandlerPackagesProcess( );
384380

381+
// Check if a package transmission is pending.
382+
// If it is the case exit function earlier
383+
if( LmHandlerPackageIsTxPending( ) == true )
384+
{
385+
return;
386+
}
387+
385388
// If a MAC layer scheduled uplink is still pending try to send it.
386389
if( IsUplinkTxPending == true )
387390
{
@@ -1014,6 +1017,21 @@ static void LmHandlerPackagesNotify( PackageNotifyTypes_t notifyType, void *para
10141017
}
10151018
}
10161019

1020+
static bool LmHandlerPackageIsTxPending( void )
1021+
{
1022+
for( int8_t i = 0; i < PKG_MAX_NUMBER; i++ )
1023+
{
1024+
if( LmHandlerPackages[i] != NULL )
1025+
{
1026+
if( LmHandlerPackages[i]->IsTxPending( ) == true )
1027+
{
1028+
return true;
1029+
}
1030+
}
1031+
}
1032+
return false;
1033+
}
1034+
10171035
static void LmHandlerPackagesProcess( void )
10181036
{
10191037
for( int8_t i = 0; i < PKG_MAX_NUMBER; i++ )

src/apps/LoRaMac/common/LmHandler/packages/LmhpCompliance.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,9 @@ static void LmhpComplianceProcess( void )
237237
{
238238
if( ComplianceTestState.IsTxPending == true )
239239
{
240-
if( TimerGetCurrentTime( ) > ( ComplianceTestState.TxPendingTimestamp + LmHandlerGetDutyCycleWaitTime( ) ) )
240+
TimerTime_t now = TimerGetCurrentTime( );
241+
if( now > ( ComplianceTestState.TxPendingTimestamp + LmHandlerGetDutyCycleWaitTime( ) ) )
241242
{
242-
ComplianceTestState.IsTxPending = false;
243-
ComplianceTestState.TxPendingTimestamp = TimerGetCurrentTime( );
244-
245243
if( ComplianceTestState.DataBufferSize != 0 )
246244
{
247245
// Answer commands
@@ -256,6 +254,11 @@ static void LmhpComplianceProcess( void )
256254
// try to send the message again
257255
ComplianceTestState.IsTxPending = true;
258256
}
257+
else
258+
{
259+
ComplianceTestState.IsTxPending = false;
260+
}
261+
ComplianceTestState.TxPendingTimestamp = now;
259262
}
260263
}
261264
}
@@ -489,6 +492,11 @@ static void LmhpComplianceOnMcpsIndication( McpsIndication_t* mcpsIndication )
489492
{
490493
ComplianceTestState.IsTxPending = true;
491494
}
495+
else
496+
{
497+
// Abort any pending Tx as a new command has been processed
498+
ComplianceTestState.IsTxPending = false;
499+
}
492500
}
493501

494502
static void LmhpComplianceOnMlmeConfirm( MlmeConfirm_t *mlmeConfirm )

0 commit comments

Comments
 (0)