AP menu
All checks were successful
ESP32 Build & Release / build (push) Successful in 6m40s

This commit is contained in:
2026-09-12 13:47:34 +02:00
parent d691febfe4
commit 3708674bbb
14 changed files with 289 additions and 120 deletions

View File

@@ -17,20 +17,6 @@ static const char *TAG = "storage";
#define STORAGE_PARTITION_LABEL "storage"
static const char SAMPLE_MAPPINGS[] =
"{\n"
" \"04A2B3C4\": \"Sol Ring\",\n"
" \"04E1F2A3\": \"Atraxa, Praetors' Voice\"\n"
"}\n";
static const char SAMPLE_CARD[] =
"{\n"
" \"name\": \"Sol Ring\",\n"
" \"mana_cost\": \"{1}\",\n"
" \"type\": \"Artifact\",\n"
" \"oracle\": \"Tap: Add CC.\",\n"
" \"price_usd\": \"1.25\"\n"
"}\n";
bool storage_file_exists(const char *path)
{
@@ -222,22 +208,12 @@ esp_err_t storage_manager_lookup_name(const char *uid, char **out)
static esp_err_t seed_defaults(void)
{
/* Create /spiffs/cards directory */
/* Ensure /spiffs/cards directory exists */
mkdir(STORAGE_CARDS_DIR, 0755);
if (!storage_file_exists(STORAGE_MAPPINGS)) {
ESP_LOGI(TAG, "seeding %s", STORAGE_MAPPINGS);
esp_err_t ret = storage_write_text(STORAGE_MAPPINGS, SAMPLE_MAPPINGS);
if (ret != ESP_OK) {
return ret;
}
}
char sample_path[64];
snprintf(sample_path, sizeof(sample_path), STORAGE_CARDS_DIR "/sample.json");
if (!storage_file_exists(sample_path)) {
ESP_LOGI(TAG, "seeding %s", sample_path);
esp_err_t ret = storage_write_text(sample_path, SAMPLE_CARD);
ESP_LOGI(TAG, "Creating empty %s", STORAGE_MAPPINGS);
esp_err_t ret = storage_write_text(STORAGE_MAPPINGS, "{\n}\n");
if (ret != ESP_OK) {
return ret;
}