forked from kofal.net/zmk
feat: Add function to erase all settings
Added a zmk_settings_erase() function to clear all saved settings. This does not go through Zephyr's settings subsystem, but instead directly clears the data from the setting storage backend, so a reboot is needed for it to take effect.
This commit is contained in:
committed by
Pete Johanson
parent
2adaa00d10
commit
610a806c84
23
app/src/settings/reset_settings_file.c
Normal file
23
app/src/settings/reset_settings_file.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2023 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/fs/fs.h>
|
||||
|
||||
#include <zmk/settings.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
int zmk_settings_erase(void) {
|
||||
LOG_INF("Erasing settings file");
|
||||
|
||||
int rc = fs_unlink(CONFIG_SETTINGS_FS_FILE);
|
||||
if (rc) {
|
||||
LOG_ERR("Failed to unlink '%s': %d", CONFIG_SETTINGS_FS_FILE, rc);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
Reference in New Issue
Block a user