mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 08:07:47 +00:00
[operational-dataset] only generate active dataset once (#4304)
Add check to see if Active Timestamp already exists in the Active Operational Dataset. If Active Timestamp exists, do not generate Active Operational Dataset again.
This commit is contained in:
@@ -80,6 +80,15 @@ public:
|
||||
*/
|
||||
bool IsSaved(void) const { return mSaved; }
|
||||
|
||||
/**
|
||||
* This method indicates whether an Active (Pending) Timestamp is present in the Active (Pending) Dataset.
|
||||
*
|
||||
* @retval TRUE if an Active/Pending Timestamp is present.
|
||||
* @retval FALSE if an Active/Pending Timestamp is not present.
|
||||
*
|
||||
*/
|
||||
bool IsTimestampPresent(void) const { return mTimestampPresent; }
|
||||
|
||||
/**
|
||||
* This method restores and retrieves the dataset from non-volatile memory.
|
||||
*
|
||||
|
||||
@@ -391,7 +391,8 @@ public:
|
||||
/**
|
||||
* This method generate a default Active Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully generated an Active Operational Dataset.
|
||||
* @retval OT_ERROR_NONE Successfully generated an Active Operational Dataset.
|
||||
* @retval OT_ERROR_ALREADY A valid Active Operational Dataset already exists.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not currently attached to a network.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -370,6 +370,7 @@ otError ActiveDataset::GenerateLocal(void)
|
||||
Dataset dataset(mLocal.GetType());
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsAttached(), error = OT_ERROR_INVALID_STATE);
|
||||
VerifyOrExit(!mLocal.IsTimestampPresent(), error = OT_ERROR_ALREADY);
|
||||
|
||||
mLocal.Read(dataset);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user