This commit is contained in:
wdfk-prog 2024-12-10 13:02:53 +01:00 committed by GitHub
commit f7f0f30d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 8 deletions

View File

@ -316,6 +316,14 @@ typedef struct sLoRaMacCtx
* Buffer containing the MAC layer commands
*/
uint8_t MacCommandsBuffer[LORA_MAC_COMMAND_MAX_LENGTH];
/*!
* Time on air accumulation
*/
uint32_t SumSendTime;
/*!
* Send count accumulation
*/
uint32_t SumSendCount;
}LoRaMacCtx_t;
/*!
@ -1042,6 +1050,10 @@ static void ProcessRadioTxDone( void )
TimerSetValue( &MacCtx.AckTimeoutTimer, MacCtx.RxWindow2Delay + phyParam.Value );
TimerStart( &MacCtx.AckTimeoutTimer );
}
else if( MacCtx.NodeAckRequested == false )
{
MacCtx.McpsConfirm.Status = LORAMAC_EVENT_INFO_STATUS_OK;
}
#elif (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 )))
if( MacCtx.NodeAckRequested == true )
{
@ -1072,13 +1084,6 @@ static void ProcessRadioTxDone( void )
}
RegionSetBandTxDone( Nvm.MacGroup2.Region, &txDone );
#if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 ))
if( MacCtx.NodeAckRequested == false )
{
MacCtx.McpsConfirm.Status = LORAMAC_EVENT_INFO_STATUS_OK;
}
#endif /* LORAMAC_VERSION */
}
static void PrepareRxDoneAbort( void )
@ -4012,6 +4017,9 @@ static LoRaMacStatus_t SendFrameOnChannel( uint8_t channel )
MacCtx.McpsConfirm.TxPower = txPower;
MacCtx.McpsConfirm.Channel = channel;
MacCtx.SumSendCount++;
MacCtx.SumSendTime += MacCtx.TxTimeOnAir;
// Store the time on air
MacCtx.McpsConfirm.TxTimeOnAir = MacCtx.TxTimeOnAir;
MacCtx.MlmeConfirm.TxTimeOnAir = MacCtx.TxTimeOnAir;
@ -6672,3 +6680,24 @@ LoRaMacStatus_t LoRaMacDeInitialization( void )
return LORAMAC_STATUS_BUSY;
}
}
uint8_t LoRaMacGetMaxPayloadLength(void)
{
return GetMaxAppPayloadWithoutFOptsLength(Nvm.MacGroup2.ChannelsDatarateDefault);
}
void LoRaMacSendInfoGet(uint32_t *count, uint32_t *time)
{
if(count != NULL) {
*count = MacCtx.SumSendCount;
}
if(time != NULL) {
*time = MacCtx.SumSendTime;
}
}
void LoRaMacSendInfoClear(void)
{
MacCtx.SumSendCount = 0;
MacCtx.SumSendTime = 0;
}

View File

@ -476,6 +476,26 @@ LoRaMacStatus_t LoRaMacDeInitialization( void );
LoRaMacStatus_t LoRaMacProcessMicForDatablock( uint8_t *buffer, uint32_t size, uint16_t sessionCnt, uint8_t fragIndex, uint32_t descriptor, uint32_t *mic );
/*!
* \brief LoRaMAC gets the maximum application payload length in the absence of the optional FOpt field
*
* \retval Max length
*/
uint8_t LoRaMacGetMaxPayloadLength( void );
/*!
* \brief LoRaMAC get send info
*
* \param [out] count - Send count accumulation
* \param [out] time - Time on air accumulation
*/
void LoRaMacSendInfoGet(uint32_t *count, uint32_t *time);
/*!
* \brief LoRaMAC send info clear
*/
void LoRaMacSendInfoClear(void);
/*! \} defgroup LORAMAC */
#ifdef __cplusplus

View File

@ -272,7 +272,11 @@ uint32_t SysTimeToMs( SysTime_t sysTime )
DeltaTime.Seconds = UTIL_SYSTIMDriver.BKUPRead_Seconds();
SysTime_t calendarTime = SysTimeSub( sysTime, DeltaTime );
return calendarTime.Seconds * 1000 + calendarTime.SubSeconds;
int64_t calendar_second = calendarTime.Seconds;
int64_t calendar_subsecond = calendarTime.SubSeconds;
int64_t calendar_time = calendar_second * 1000 + calendar_subsecond;
calendar_time = calendar_time % 4194304000;
return calendar_time;
}
SysTime_t SysTimeFromMs( uint32_t timeMs )