mirror of
https://github.com/espressif/openthread.git
synced 2026-10-08 00:37:40 +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.
|
* @note This number versions both OpenThread platform and user APIs.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_API_VERSION (173)
|
#define OPENTHREAD_API_VERSION (174)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup api-instance
|
* @addtogroup api-instance
|
||||||
|
|||||||
@@ -168,10 +168,7 @@ typedef struct otMleCounters
|
|||||||
uint16_t mBetterPartitionAttachAttempts; ///< Number of attempts to attach to a better partition.
|
uint16_t mBetterPartitionAttachAttempts; ///< Number of attempts to attach to a better partition.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of times device changed its parents.
|
* Number of times device changed its parent.
|
||||||
*
|
|
||||||
* Support for this counter requires the feature option OPENTHREAD_CONFIG_MLE_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
|
* 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
|
* 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
|
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||||
, mCslTimeout(OPENTHREAD_CONFIG_CSL_TIMEOUT)
|
, mCslTimeout(OPENTHREAD_CONFIG_CSL_TIMEOUT)
|
||||||
#endif
|
#endif
|
||||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
|
||||||
, mPreviousParentRloc(Mac::kShortAddrInvalid)
|
, mPreviousParentRloc(Mac::kShortAddrInvalid)
|
||||||
#endif
|
|
||||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||||
, mParentSearchIsInBackoff(false)
|
, mParentSearchIsInBackoff(false)
|
||||||
, mParentSearchBackoffWasCanceled(false)
|
, mParentSearchBackoffWasCanceled(false)
|
||||||
@@ -386,9 +384,7 @@ Error Mle::Restore(void)
|
|||||||
mParent.SetRloc16(Rloc16FromRouterId(RouterIdFromRloc16(networkInfo.GetRloc16())));
|
mParent.SetRloc16(Rloc16FromRouterId(RouterIdFromRloc16(networkInfo.GetRloc16())));
|
||||||
mParent.SetState(Neighbor::kStateRestored);
|
mParent.SetState(Neighbor::kStateRestored);
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
|
||||||
mPreviousParentRloc = mParent.GetRloc16();
|
mPreviousParentRloc = mParent.GetRloc16();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if OPENTHREAD_FTD
|
#if OPENTHREAD_FTD
|
||||||
else
|
else
|
||||||
@@ -693,10 +689,16 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
|||||||
UpdateParentSearchState();
|
UpdateParentSearchState();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ((mPreviousParentRloc != Mac::kShortAddrInvalid) && (mPreviousParentRloc != mParent.GetRloc16()))
|
||||||
|
{
|
||||||
|
mCounters.mParentChanges++;
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||||
InformPreviousParent();
|
InformPreviousParent();
|
||||||
mPreviousParentRloc = mParent.GetRloc16();
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
mPreviousParentRloc = mParent.GetRloc16();
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||||
if (Get<Mac::Mac>().IsCslCapable())
|
if (Get<Mac::Mac>().IsCslCapable())
|
||||||
@@ -4155,10 +4157,6 @@ void Mle::InformPreviousParent(void)
|
|||||||
Message * message = nullptr;
|
Message * message = nullptr;
|
||||||
Ip6::MessageInfo messageInfo;
|
Ip6::MessageInfo messageInfo;
|
||||||
|
|
||||||
VerifyOrExit((mPreviousParentRloc != Mac::kShortAddrInvalid) && (mPreviousParentRloc != mParent.GetRloc16()));
|
|
||||||
|
|
||||||
mCounters.mParentChanges++;
|
|
||||||
|
|
||||||
VerifyOrExit((message = Get<Ip6::Ip6>().NewMessage(0)) != nullptr, error = kErrorNoBufs);
|
VerifyOrExit((message = Get<Ip6::Ip6>().NewMessage(0)) != nullptr, error = kErrorNoBufs);
|
||||||
SuccessOrExit(error = message->SetLength(0));
|
SuccessOrExit(error = message->SetLength(0));
|
||||||
|
|
||||||
|
|||||||
@@ -1887,9 +1887,7 @@ private:
|
|||||||
uint32_t mCslTimeout;
|
uint32_t mCslTimeout;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
|
||||||
uint16_t mPreviousParentRloc;
|
uint16_t mPreviousParentRloc;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||||
bool mParentSearchIsInBackoff : 1;
|
bool mParentSearchIsInBackoff : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user