[mle] add mHasRestored flag (#5228)

This commit introduces the mHasRestored flag and a common
HasRestored() method as devices may decide to introduce some
jitter/randomization to avoid the burst of traffic in cases a bunch of
devices nearby resets/reboots together.
This commit is contained in:
Rongli Sun
2020-07-20 23:24:57 -07:00
committed by GitHub
parent 2d38c59a5a
commit 6c1abeab90
2 changed files with 15 additions and 0 deletions
+4
View File
@@ -86,6 +86,7 @@ Mle::Mle(Instance &aInstance)
, mDataRequestAttempts(0)
, mDataRequestState(kDataRequestNone)
, mAddressRegistrationMode(kAppendAllAddresses)
, mHasRestored(false)
, mParentLinkMargin(0)
, mParentIsSingleton(false)
, mReceivedResponseFromParent(false)
@@ -439,6 +440,9 @@ otError Mle::Restore(void)
}
#endif
// Sucessfully restored the network information from non-volatile settings after boot.
mHasRestored = true;
exit:
return error;
}
+11
View File
@@ -915,6 +915,16 @@ public:
*/
otError GetLocatorAddress(Ip6::Address &aAddress, uint16_t aLocator) const;
/**
* This method indicates whether or not the device has restored the network information from
* non-volatile settings after boot.
*
* @retval true Sucessfully restored the network information.
* @retval false No valid network information was found.
*
*/
bool HasRestored(void) const { return mHasRestored; }
protected:
/**
* States during attach (when searching for a parent).
@@ -1734,6 +1744,7 @@ private:
AddressRegistrationMode mAddressRegistrationMode;
bool mHasRestored;
uint8_t mParentLinkMargin;
bool mParentIsSingleton;
bool mReceivedResponseFromParent;