summaryrefslogtreecommitdiff
path: root/src/drivers/spiffs.cpp
blob: 9a85c0d3dab16d8588fc4e269fa697e030a5ee5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright 2023 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#include "spiffs.hpp"

#include "esp_err.h"
#include "esp_log.h"
#include "esp_spiffs.h"

namespace drivers {

[[maybe_unused]] static constexpr char kTag[] = "spiffs";

esp_err_t spiffs_mount() {
  esp_vfs_spiffs_conf_t config{
      .base_path = "/lua",
      .partition_label = "lua",
      .max_files = 5,
      .format_if_mount_failed = false,
  };

  esp_err_t res = esp_vfs_spiffs_register(&config);
  if (res == ESP_OK) {
    size_t total, used;
    esp_spiffs_info("lua", &total, &used);
    ESP_LOGI(kTag, "spiffs mounted okay. %d / %d ", used / 1024, total / 1024);
  }

  return res;
}

}  // namespace drivers