[posix-app] close the settings file when reset (#3958)

Currently, the Setting file won't be closed after ot-ncp is reset.
Once ot-ncp receives a RESET command from wpantund, it will reopen
the Setting file and create a new file Id.

This commit closes the Setting file when ot-ncp is reset.
This commit is contained in:
Zhanglong Xia
2019-07-08 21:21:14 -07:00
committed by Jonathan Hui
parent b983974aec
commit 8de5fbeae7
11 changed files with 54 additions and 2 deletions
+5
View File
@@ -55,6 +55,11 @@ void otPlatSettingsInit(otInstance *aInstance)
qorvoSettingsInit();
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
{
otError error = OT_ERROR_NOT_FOUND;
@@ -303,6 +303,11 @@ void otPlatSettingsInit(otInstance *aInstance)
}
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
otError otPlatSettingsBeginChange(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
+8
View File
@@ -60,6 +60,14 @@ extern "C" {
*/
void otPlatSettingsInit(otInstance *aInstance);
/**
* Performs any de-initialization for the settings subsystem, if necessary.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
void otPlatSettingsDeinit(otInstance *aInstance);
/// Fetches the value of a setting
/** This function fetches the value of the setting identified
* by aKey and write it to the memory pointed to by aValue.
+2
View File
@@ -178,6 +178,8 @@ void Instance::Finalize(void)
IgnoreReturnValue(otThreadSetEnabled(this, false));
IgnoreReturnValue(otIp6SetEnabled(this, false));
IgnoreReturnValue(otLinkSetEnabled(this, false));
Get<Settings>().Deinit();
#endif
#if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
+5
View File
@@ -97,6 +97,11 @@ void Settings::Init(void)
otPlatSettingsInit(&GetInstance());
}
void Settings::Deinit(void)
{
otPlatSettingsDeinit(&GetInstance());
}
void Settings::Wipe(void)
{
otPlatSettingsWipe(&GetInstance());
+8
View File
@@ -182,6 +182,14 @@ public:
*/
void Init(void);
/**
* This method de-initializes the platform settings (non-volatile) module.
*
* This method should be called when OpenThread instance is no longer in use.
*
*/
void Deinit(void);
/**
* This method removes all settings from the non-volatile store.
*
+1
View File
@@ -144,6 +144,7 @@ int main(int argc, char *argv[])
otxConsoleDeinit();
#endif
otInstanceFinalize(instance);
otSysDeinit();
return 0;
}
+1 -2
View File
@@ -45,8 +45,7 @@ static otPlatMcuPowerState gPlatMcuPowerState = OT_PLAT_MCU_POWER_STATE_ON;
void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
otInstanceFinalize(aInstance);
otSysDeinit();
longjmp(gResetJump, 1);
+9
View File
@@ -180,6 +180,14 @@ exit:
}
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
assert(sSettingsFd != -1);
VerifyOrDie(close(sSettingsFd) == 0);
}
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
{
OT_UNUSED_VARIABLE(aInstance);
@@ -484,6 +492,7 @@ int main()
assert(otPlatSettingsGet(instance, 0, 0, NULL, NULL) == OT_ERROR_NOT_FOUND);
}
otPlatSettingsWipe(instance);
otPlatSettingsDeinit(instance);
return 0;
}
+5
View File
@@ -353,6 +353,11 @@ void otPlatSettingsInit(otInstance *aInstance)
OT_UNUSED_VARIABLE(aInstance);
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
otError otPlatSettingsBeginChange(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
+5
View File
@@ -487,6 +487,11 @@ void otPlatSettingsInit(otInstance *aInstance)
OT_UNUSED_VARIABLE(aInstance);
}
void otPlatSettingsDeinit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
otError otPlatSettingsBeginChange(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);