[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:
Jonathan Hui
2019-11-07 04:51:47 -08:00
committed by GitHub
parent 75bb2a9dd1
commit c8c26b7ac0
3 changed files with 12 additions and 1 deletions
+9
View File
@@ -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.
*
+2 -1
View File
@@ -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.
*
*/
+1
View File
@@ -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);