ChaosDMX
Open-Source DMX-Interface
Loading...
Searching...
No Matches
storage.c File Reference
#include "storage.h"
#include "esp_littlefs.h"
#include "esp_vfs.h"
#include "logger.h"
Include dependency graph for storage.c:

Go to the source code of this file.

Macros

#define LOG_TAG   "STORE"
 "STORE" log tag for this file

Functions

esp_err_t storage_init (void)
 Initialize and mount LittleFS filesystem.
bool storage_is_mounted (void)
 Check if the storage is mounted and ready.
const char * storage_get_mount_point (void)
 Get the mount point for the LittleFS filesystem.
const char * storage_get_partition_label (void)
 Get the partition label for the LittleFS filesystem.
esp_err_t storage_get_info (storage_info_t *info)
 Get comprehensive storage information.
void storage_print_info (void)
 Print storage information to the log.
size_t storage_get_total_bytes (void)
 Get the total size of the storage in bytes.
size_t storage_get_used_bytes (void)
 Get the used size of the storage in bytes.
size_t storage_get_free_bytes (void)
 Get the free size of the storage in bytes.

Variables

static const char * LITTLEFS_MOUNT_POINT
 Mount point for LittleFS filesystem.
static const char * LITTLEFS_PARTITION_LABEL = "storage"
 Partition label for the LittleFS filesystem.
static bool is_mounted = false
 Flag indicating if the filesystem is currently mounted.

Macro Definition Documentation

◆ LOG_TAG

#define LOG_TAG   "STORE"

"STORE" log tag for this file

Definition at line 1 of file storage.c.

Function Documentation

◆ storage_get_free_bytes()

size_t storage_get_free_bytes ( void )

Get the free size of the storage in bytes.

Returns
Free size in bytes, or 0 on error

Definition at line 121 of file storage.c.

References storage_info_t::free_bytes, and storage_get_info().

Here is the call graph for this function:

◆ storage_get_info()

esp_err_t storage_get_info ( storage_info_t * info)

Get comprehensive storage information.

Parameters
[out]infoPointer to storage_info_t structure to fill
Returns
ESP_OK on success, error code otherwise

Definition at line 58 of file storage.c.

References storage_info_t::free_bytes, is_mounted, LITTLEFS_PARTITION_LABEL, storage_info_t::total_bytes, and storage_info_t::used_bytes.

Referenced by storage_get_free_bytes(), storage_get_total_bytes(), storage_get_used_bytes(), and storage_print_info().

Here is the caller graph for this function:

◆ storage_get_mount_point()

const char * storage_get_mount_point ( void )

Get the mount point for the LittleFS filesystem.

Returns
Pointer to the mount point string (e.g., "/data")

Definition at line 52 of file storage.c.

References LITTLEFS_MOUNT_POINT.

Referenced by static_file_handler().

Here is the caller graph for this function:

◆ storage_get_partition_label()

const char * storage_get_partition_label ( void )

Get the partition label for the LittleFS filesystem.

Returns
Pointer to the partition label string

Definition at line 54 of file storage.c.

References LITTLEFS_PARTITION_LABEL.

◆ storage_get_total_bytes()

size_t storage_get_total_bytes ( void )

Get the total size of the storage in bytes.

Returns
Total size in bytes, or 0 on error

Definition at line 105 of file storage.c.

References storage_get_info(), and storage_info_t::total_bytes.

Here is the call graph for this function:

◆ storage_get_used_bytes()

size_t storage_get_used_bytes ( void )

Get the used size of the storage in bytes.

Returns
Used size in bytes, or 0 on error

Definition at line 113 of file storage.c.

References storage_get_info(), and storage_info_t::used_bytes.

Here is the call graph for this function:

◆ storage_init()

esp_err_t storage_init ( void )

Initialize and mount LittleFS filesystem.

Returns
ESP_OK on success, error code otherwise

Definition at line 15 of file storage.c.

References is_mounted, LITTLEFS_MOUNT_POINT, LITTLEFS_PARTITION_LABEL, LOGE, and LOGI.

Referenced by webserver_start().

Here is the caller graph for this function:

◆ storage_is_mounted()

bool storage_is_mounted ( void )

Check if the storage is mounted and ready.

Returns
true if mounted, false otherwise

Definition at line 50 of file storage.c.

References is_mounted.

◆ storage_print_info()

void storage_print_info ( void )

Print storage information to the log.

Definition at line 80 of file storage.c.

References storage_info_t::free_bytes, is_mounted, LITTLEFS_MOUNT_POINT, LITTLEFS_PARTITION_LABEL, LOGE, LOGI, storage_get_info(), storage_info_t::total_bytes, and storage_info_t::used_bytes.

Referenced by app_main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ is_mounted

bool is_mounted = false
static

Flag indicating if the filesystem is currently mounted.

Definition at line 13 of file storage.c.

Referenced by storage_get_info(), storage_init(), storage_is_mounted(), and storage_print_info().

◆ LITTLEFS_MOUNT_POINT

const char* LITTLEFS_MOUNT_POINT
static
Initial value:
=
"/data"

Mount point for LittleFS filesystem.

Definition at line 8 of file storage.c.

Referenced by storage_get_mount_point(), storage_init(), and storage_print_info().

◆ LITTLEFS_PARTITION_LABEL

const char* LITTLEFS_PARTITION_LABEL = "storage"
static

Partition label for the LittleFS filesystem.

Definition at line 11 of file storage.c.

Referenced by storage_get_info(), storage_get_partition_label(), storage_init(), and storage_print_info().