[mle] fix how time per role is tracked after counters are reset (#9011)

This commit fixes an issue with tracking time spent in each role after
`Mle::ResetCounters()`. The  `mLastUpdatedTimestamp` is now updated
from `ResetCounters()`.
This commit is contained in:
Abtin Keshavarzian
2023-05-02 12:05:17 -07:00
committed by GitHub
parent 6b7cbbcd7b
commit b9a318092c
3 changed files with 18 additions and 3 deletions
+8
View File
@@ -259,6 +259,14 @@ exit:
}
}
void Mle::ResetCounters(void)
{
memset(&mCounters, 0, sizeof(mCounters));
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
mLastUpdatedTimestamp = Get<Uptime>().GetUptime();
#endif
}
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
void Mle::UpdateRoleTimeCounters(DeviceRole aRole)
{
+4 -3
View File
@@ -610,7 +610,7 @@ public:
* @returns A reference to the MLE counters.
*
*/
const otMleCounters &GetCounters(void)
const Counters &GetCounters(void)
{
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
UpdateRoleTimeCounters(mRole);
@@ -622,7 +622,7 @@ public:
* This method resets the MLE counters.
*
*/
void ResetCounters(void) { memset(&mCounters, 0, sizeof(mCounters)); }
void ResetCounters(void);
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
/**
@@ -2122,10 +2122,11 @@ private:
ServiceAloc mServiceAlocs[kMaxServiceAlocs];
#endif
otMleCounters mCounters;
Counters mCounters;
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
uint64_t mLastUpdatedTimestamp;
#endif
static const otMeshLocalPrefix sMeshLocalPrefixInit;
Ip6::Netif::UnicastAddress mLinkLocal64;
+6
View File
@@ -646,6 +646,12 @@ typedef Mac::KeyMaterial KeyMaterial;
*/
typedef Mac::Key Key;
/**
* This structure represents the Thread MLE counters.
*
*/
typedef otMleCounters Counters;
/**
* This function derives the Child ID from a given RLOC16.
*