Remove restore method for local operational dataset. (#1958)

With the local operational dataset being retrieved from non-volatile storage
on demand, the restore method is now no longer necessary.

This PR also fixes a bug in initializing the in-memory dataset representation
when no operational dataset exists in non-volatile storage.
This commit is contained in:
Jonathan Hui
2017-07-06 09:58:38 -07:00
committed by GitHub
parent 10b72cfa5d
commit 5f97abc356
2 changed files with 4 additions and 27 deletions
+3 -20
View File
@@ -76,9 +76,8 @@ otError DatasetLocal::Get(Dataset &aDataset)
otError error;
aDataset.mLength = sizeof(aDataset.mTlvs);
error = otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, aDataset.mTlvs, &aDataset.mLength);
SuccessOrExit(error);
VerifyOrExit(error == OT_ERROR_NONE, aDataset.mLength = 0);
delayTimer = static_cast<DelayTimerTlv *>(aDataset.Get(Tlv::kDelayTimer));
VerifyOrExit(delayTimer);
@@ -107,16 +106,15 @@ otError DatasetLocal::Get(otOperationalDataset &aDataset) const
const Tlv *cur;
const Tlv *end;
dataset.mLength = sizeof(dataset.mTlvs);
memset(&aDataset, 0, sizeof(aDataset));
dataset.mLength = sizeof(dataset.mTlvs);
error = otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, dataset.mTlvs, &dataset.mLength);
SuccessOrExit(error);
cur = reinterpret_cast<const Tlv *>(dataset.mTlvs);
end = reinterpret_cast<const Tlv *>(dataset.mTlvs + dataset.mLength);
memset(&aDataset, 0, sizeof(aDataset));
while (cur < end)
{
switch (cur->GetType())
@@ -404,21 +402,6 @@ exit:
return error;
}
otError DatasetLocal::Restore(void)
{
Dataset dataset(mType);
otError error;
dataset.mLength = sizeof(dataset.mTlvs);
error = otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, dataset.mTlvs, &dataset.mLength);
SuccessOrExit(error);
mUpdateTime = Timer::GetNow();
exit:
return error;
}
uint16_t DatasetLocal::GetSettingsKey(void) const
{
uint16_t rval;
+1 -7
View File
@@ -204,13 +204,7 @@ otError DatasetManager::ApplyConfiguration(void)
otError DatasetManager::Restore(void)
{
otError error;
SuccessOrExit(error = mLocal.Restore());
mLocal.Get(mNetwork);
exit:
return error;
return mLocal.Get(mNetwork);
}
void DatasetManager::Clear(void)