subsys: settings: Idea for a very simple settings system #8378
The way the settings system is extended for bt-mesh storage inspired me to a very simple settings system that could be easily used by multiple subsystems and also the user application:
Instead of using names to identify storage items id are used. Each subsystem that requires settings storage registers its own set, commit and export handles for a range of id's that it will use. The method for this is similar to BT_SETTINGS_DEFINE as defined in settings.h (bluetooth/host/settings.h). The settings module itself just calls the required handle based upon the id of the setting (similar to the set, commit and export routines in bluetooth/host/settings.c). The subsystem that requires settings can then further divide the range into smaller ranges (like is done in bluetooth/host/mesh/settings.c) but this is invisible to the settings module.
At start the settings module can read through the file with settings and determine based upon the id which (subsystem) set routine it has to call. The storage of an id-value is also very easy to do in fcb, nffs and also nvs. For nffs it might be required to encode the data, but for fcb and nvs it is not required. For fcb the entry could contain the id at the end, for nvs the id is already available.
The advantages would be: