Skip to content

Commit

Permalink
Allow full reset
Browse files Browse the repository at this point in the history
  • Loading branch information
revk committed Dec 19, 2024
1 parent 1492893 commit c9e7be7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions revk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ task (void *pvParameters)
if (b.factorycount == 3)
{ // Do factory reset
const esp_app_desc_t *app = esp_app_get_description ();
revk_settings_factory (TAG, app->project_name);
revk_settings_factory (TAG, app->project_name, 0);
revk_restart (3, "Factory reset");
}
}
Expand Down Expand Up @@ -4447,7 +4447,7 @@ revk_command (const char *tag, jo_t j)
if (strcmp (val + strlen (revk_id), appname))
return "Bad appname";
const esp_app_desc_t *app = esp_app_get_description ();
revk_settings_factory (TAG, app->project_name);
revk_settings_factory (TAG, app->project_name, 0);
revk_restart (3, "Factory reset");
return "";
}
Expand Down
4 changes: 3 additions & 1 deletion settings_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ revk_settings_load (const char *tag, const char *appname)
}

void
revk_settings_factory (const char *tag, const char *appname)
revk_settings_factory (const char *tag, const char *appname, char full)
{ // Factory reset settings
ESP_LOGE (tag, "Factory reset");
for (int revk = 0; revk < 2; revk++)
Expand All @@ -1088,6 +1088,8 @@ revk_settings_factory (const char *tag, const char *appname)
esp_err_t e = nvs_flash_erase ();
if (!e)
e = nvs_flash_erase_partition (tag);
if (full)
return;
// Restore fixed settings
nvs_flash_init ();
ESP_LOGE (tag, "Fixed settings");
Expand Down
2 changes: 1 addition & 1 deletion settings_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
void revk_settings_load (const char *tag, const char *appname);
const char *revk_setting_dump (int level);
void revk_settings_commit (void);
void revk_settings_factory (const char *tag,const char *appname);
void revk_settings_factory (const char *tag,const char *appname,char full);
#ifndef CONFIG_REVK_OLD_SETTINGS
revk_settings_t *revk_settings_find (const char *name, int *index);
int revk_settings_set (revk_settings_t *);
Expand Down
4 changes: 2 additions & 2 deletions settings_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,11 +1137,11 @@ revk_settings_commit (void)
}

static void
revk_settings_factory (const char *tag, const char *appname)
revk_settings_factory (const char *tag, const char *appname, char full)
{ // Factory reset settings
esp_err_t e = nvs_flash_erase ();
if (!e)
e = nvs_flash_erase_partition (TAG);
e = nvs_flash_erase_partition (tag);
}

#endif

0 comments on commit c9e7be7

Please sign in to comment.