mirror of
https://github.com/espressif/openthread.git
synced 2026-08-27 12:29:54 +00:00
[mle] mParentChanges counter without INFORM_PREVIOUS_PARENT (#7134)
This commit allows `mParentChanges` counter which tracks the number of times device (as a child) switches its parent to be used without `INFORM_PREVIOUS_PARENT` feature.
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (173)
|
||||
#define OPENTHREAD_API_VERSION (174)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -168,10 +168,7 @@ typedef struct otMleCounters
|
||||
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_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH to
|
||||
* be enabled.
|
||||
* Number of times device changed its parent.
|
||||
*
|
||||
* 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
|
||||
|
||||
+8
-10
@@ -97,9 +97,7 @@ Mle::Mle(Instance &aInstance)
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
, mCslTimeout(OPENTHREAD_CONFIG_CSL_TIMEOUT)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
, mPreviousParentRloc(Mac::kShortAddrInvalid)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
, mParentSearchIsInBackoff(false)
|
||||
, mParentSearchBackoffWasCanceled(false)
|
||||
@@ -386,9 +384,7 @@ Error Mle::Restore(void)
|
||||
mParent.SetRloc16(Rloc16FromRouterId(RouterIdFromRloc16(networkInfo.GetRloc16())));
|
||||
mParent.SetState(Neighbor::kStateRestored);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
mPreviousParentRloc = mParent.GetRloc16();
|
||||
#endif
|
||||
}
|
||||
#if OPENTHREAD_FTD
|
||||
else
|
||||
@@ -693,10 +689,16 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
||||
UpdateParentSearchState();
|
||||
#endif
|
||||
|
||||
if ((mPreviousParentRloc != Mac::kShortAddrInvalid) && (mPreviousParentRloc != mParent.GetRloc16()))
|
||||
{
|
||||
mCounters.mParentChanges++;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
InformPreviousParent();
|
||||
mPreviousParentRloc = mParent.GetRloc16();
|
||||
InformPreviousParent();
|
||||
#endif
|
||||
}
|
||||
|
||||
mPreviousParentRloc = mParent.GetRloc16();
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
if (Get<Mac::Mac>().IsCslCapable())
|
||||
@@ -4155,10 +4157,6 @@ void Mle::InformPreviousParent(void)
|
||||
Message * message = nullptr;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit((mPreviousParentRloc != Mac::kShortAddrInvalid) && (mPreviousParentRloc != mParent.GetRloc16()));
|
||||
|
||||
mCounters.mParentChanges++;
|
||||
|
||||
VerifyOrExit((message = Get<Ip6::Ip6>().NewMessage(0)) != nullptr, error = kErrorNoBufs);
|
||||
SuccessOrExit(error = message->SetLength(0));
|
||||
|
||||
|
||||
@@ -1887,9 +1887,7 @@ private:
|
||||
uint32_t mCslTimeout;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
uint16_t mPreviousParentRloc;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
bool mParentSearchIsInBackoff : 1;
|
||||
|
||||
Reference in New Issue
Block a user