mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
[settings] simplify and enhance Settings (#6683)
This commit updates the `Settings` implementation. It adds template versions of methods `Read<EntryType>()`, `Save<EntryType>()`, and `Delete<EntryType>()` which make it easier for other modules to use, while ensuing to share a common underlying implementation for all entry types. The settings entry types (e.g., `NetworkInfo`, `ParentInfo`, etc.) are changed in this commit to provide a constant `kKey` specifying the associated setting key with the entry. For simple entries, a related class is added to define the `kKey` constant and the associated value type (e.g., `OmrPrefix` defines `Ip6::Prefix` as its `ValueType`). This model makes it easier to add new setting keys and entries in future. This commit also simplifies the logging in `Settings`. The entry types now provide `Log()` method to log their data and a common `Settings::Log()` method is added which handles all logging (on success or in case of an error). Finally, this commit moves the `SettingsDriver` definition to its own `common/settings_driver.hpp` header file and and ensures that its methods are defined as inline.
This commit is contained in:
@@ -213,7 +213,7 @@ void DuaManager::Restore(void)
|
||||
{
|
||||
Settings::DadInfo dadInfo;
|
||||
|
||||
SuccessOrExit(Get<Settings>().ReadDadInfo(dadInfo));
|
||||
SuccessOrExit(Get<Settings>().Read(dadInfo));
|
||||
mDadCounter = dadInfo.GetDadCounter();
|
||||
|
||||
exit:
|
||||
@@ -225,7 +225,7 @@ Error DuaManager::Store(void)
|
||||
Settings::DadInfo dadInfo;
|
||||
|
||||
dadInfo.SetDadCounter(mDadCounter);
|
||||
return Get<Settings>().SaveDadInfo(dadInfo);
|
||||
return Get<Settings>().Save(dadInfo);
|
||||
}
|
||||
|
||||
void DuaManager::AddDomainUnicastAddress(void)
|
||||
|
||||
Reference in New Issue
Block a user