27 static constexpr const char * file_path =
"/spiffs/session_storage.json";
28 static constexpr std::size_t buffer_size = 1024;
30 char buffer[buffer_size];
31 rapidjson::FileWriteStream ostream;
32 rapidjson::Writer<rapidjson::FileWriteStream> writer;
34 : fp{std::fopen(file_path,
"w")}, buffer{0}
35 , ostream{fp, buffer, buffer_size}, writer{ostream}
37 if (fp ==
nullptr) printf(
"spiffs: unable to open file for writing!\n");
48:
name_<"SPIFFS Session Storage">
51 static constexpr const char * spiffs_base_path =
"/spiffs";
52 static constexpr const char * file_path = SpiffsJsonOStream::file_path;
53 static constexpr std::size_t buffer_size = SpiffsJsonOStream::buffer_size;
55 void init(Components& components)
59 esp_vfs_spiffs_conf_t conf = {
60 .base_path =
"/spiffs",
61 .partition_label = NULL,
63 .format_if_mount_failed =
true
65 esp_err_t ret = esp_vfs_spiffs_register(&conf);
66 ESP_ERROR_CHECK_WITHOUT_ABORT(ret);
67 if (ret != ESP_OK)
return;
69 size_t total = 0, used = 0;
70 ret = esp_spiffs_info(conf.partition_label, &total, &used);
72 printf(
"spiffs: Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret));
73 esp_spiffs_format(conf.partition_label);
76 printf(
"spiffs: Partition size: total: %d, used: %d\n", total, used);
80 printf(
"spiffs: Number of used bytes cannot be larger than total. Performing SPIFFS_check().");
81 ret = esp_spiffs_check(conf.partition_label);
85 printf(
"spiffs: SPIFFS_check() failed (%s)", esp_err_to_name(ret));
88 printf(
"spiffs: SPIFFS_check() successful");
92 std::FILE * fp = std::fopen(file_path,
"r");
93 if (fp ==
nullptr) fp = std::fopen(file_path,
"w+");
95 printf(
"spiffs: Unable to open file for initialization!\n");
98 char buffer[buffer_size];
99 rapidjson::FileReadStream istream{fp, buffer, buffer_size};
100 storage->init(istream, components);
104 void external_destinations(Components& components)
106 storage->external_destinations(components);
Document the name of an entity, e.g. an endpoint, component, or binding.
Definition sygah-metadata.hpp:33