[topology] adding Neighbor::StateToString() (#4440)

The `Neighbor::StateToString()` converts a given `Neighbor::State`
to a human-readable string.
This commit is contained in:
Abtin Keshavarzian
2020-12-10 11:46:07 -08:00
committed by Jonathan Hui
parent d23f3581ea
commit 61e77bf6ed
2 changed files with 27 additions and 0 deletions
+16
View File
@@ -197,6 +197,22 @@ void Neighbor::RemoveAllForwardTrackingSeriesInfo(void)
}
#endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE
const char *Neighbor::StateToString(State aState)
{
static const char *kStateStrings[] = {
"Invalid", // kStateInvalid
"Restored", // kStateRestored
"ParentReq", // kStateParentRequest
"ParentRes", // kStateParentResponse
"ChildIdReq", // kStateChildIdRequest
"LinkReq", // kStateLinkRequest
"ChildUpdateReq", // kStateChildUpdateRequest
"Valid", // kStateValid
};
return static_cast<uint8_t>(aState) < OT_ARRAY_LENGTH(kStateStrings) ? kStateStrings[aState] : "Unknown";
}
void Child::Info::SetFrom(const Child &aChild)
{
Clear();
+11
View File
@@ -645,6 +645,17 @@ public:
void RemoveAllForwardTrackingSeriesInfo(void);
#endif
/**
* This method converts a given `State` to a human-readable string.
*
* @param[in] aState A neighbor state.
*
* @returns A string representation of given state.
*
*/
static const char *StateToString(State aState);
protected:
/**
* This method initializes the `Neighbor` object.