mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 22:27:47 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user