[mle] add MLE counters (#2982)

This commit adds support for a set of MLE counters (e.g., counters to
track number of times device entered different roles, or counters
tracking number of attach attempts, partition ID or parent changes).
This commit is contained in:
Abtin Keshavarzian
2018-09-06 21:01:31 -10:00
committed by Jonathan Hui
parent abfb16eb7f
commit 144a4e3e06
4 changed files with 107 additions and 0 deletions
+47
View File
@@ -153,6 +153,35 @@ typedef struct otIpCounters
uint32_t mRxFailure; ///< The number of IPv6 packets failed to receive.
} otIpCounters;
/**
* This structure represents the Thread MLE counters.
*
*/
typedef struct otMleCounters
{
uint16_t mDisabledRole; ///< Number of times device entered OT_DEVICE_ROLE_DISABLED role.
uint16_t mDetachedRole; ///< Number of times device entered OT_DEVICE_ROLE_DETACHED role.
uint16_t mChildRole; ///< Number of times device entered OT_DEVICE_ROLE_CHILD role.
uint16_t mRouterRole; ///< Number of times device entered OT_DEVICE_ROLE_ROUTER role.
uint16_t mLeaderRole; ///< Number of times device entered OT_DEVICE_ROLE_LEADER role.
uint16_t mAttachAttempts; ///< Number of attach attempts while device was detached.
uint16_t mParitionIdChanges; ///< Number of changes to partition ID.
uint16_t mBetterPartitionAttachAttempts; ///< Number of attempts to attach to a better partition.
/**
* Number of times device changed its parents.
*
* Support for this counter requires the feature option OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH to be
* enabled.
*
* A parent change can happen if device detaches from its current parent and attaches to a different one, or even
* while device is attached when the periodic parent search feature is enabled (please see option
* OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH).
*
*/
uint16_t mParentChanges;
} otMleCounters;
/**
* This function starts Thread protocol operation.
*
@@ -670,6 +699,24 @@ OTAPI otError OTCALL otThreadSendDiagnosticReset(otInstance * aInstance,
*/
OTAPI const otIpCounters *OTCALL otThreadGetIp6Counters(otInstance *aInstance);
/**
* Get the Thread MLE counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to the Thread MLE counters.
*
*/
const otMleCounters *otThreadGetMleCounters(otInstance *aInstance);
/**
* Reset the Thread MLE counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
*/
void otThreadResetMleCounters(otInstance *aInstance);
/**
* @}
*