diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 587af99fe..47fa980fa 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -97,6 +97,7 @@ Mle::Mle(Instance &aInstance) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE , mCslTimeout(OPENTHREAD_CONFIG_CSL_TIMEOUT) #endif + , mRloc16(Mac::kShortAddrInvalid) , mPreviousParentRloc(Mac::kShortAddrInvalid) #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE , mParentSearch(aInstance) @@ -398,6 +399,7 @@ void Mle::Restore(void) #endif { Get().SetShortAddress(networkInfo.GetRloc16()); + mRloc16 = networkInfo.GetRloc16(); } Get().SetExtAddress(networkInfo.GetExtAddress()); @@ -984,8 +986,6 @@ exit: Get().Signal(kEventThreadMeshLocalAddrChanged); } -uint16_t Mle::GetRloc16(void) const { return Get().GetShortAddress(); } - void Mle::SetRloc16(uint16_t aRloc16) { uint16_t oldRloc16 = GetRloc16(); @@ -1003,6 +1003,7 @@ void Mle::SetRloc16(uint16_t aRloc16) } Get().SetShortAddress(aRloc16); + mRloc16 = aRloc16; if (aRloc16 != Mac::kShortAddrInvalid) { diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 8ddf74151..aeef59981 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -495,7 +495,7 @@ public: * @returns The RLOC16 assigned to the Thread interface. * */ - uint16_t GetRloc16(void) const; + uint16_t GetRloc16(void) const { return mRloc16; } /** * This method returns a reference to the RLOC assigned to the Thread interface. @@ -2019,6 +2019,7 @@ private: uint32_t mCslTimeout; #endif + uint16_t mRloc16; uint16_t mPreviousParentRloc; #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE