1#include "nvmconfig/persistent.h"
3#include <ArduinoJson.h>
5#include "utils/error.h"
6#include "utils/logging.h"
7#include "utils/streaming_json.h"
21FLASHMEM
void nvmconfig::PersistentSettingsWriter::info(JsonObject msg_out) {
24 msg_out[
"available_bytes"] = eeprom_size;
25 msg_out[
"consumed_bytes"] = write_to_eeprom();
28FLASHMEM
void nvmconfig::PersistentSettingsWriter::toJson(JsonObject target, Context c) {
29 target[
"version"] = version;
30 for (
auto const &sys : subsystems) {
31 sys->toJson(target.createNestedObject(sys->name()), c);
32 if (!target[sys->name()].size())
33 target.remove(sys->name());
37FLASHMEM
void nvmconfig::PersistentSettingsWriter::fromJson(JsonObjectConst target, Context c) {
38 for (
auto const &sys : subsystems) {
39 if (target.containsKey(sys->name()))
40 sys->fromJson(target[sys->name()], c);
44FLASHMEM
void nvmconfig::PersistentSettingsWriter::reset_defaults(
bool do_write_to_eeprom) {
45 version = required_magic;
46 for (
auto const &sys : subsystems)
47 sys->reset_defaults();
48 if (do_write_to_eeprom)