Files
RadioPhotonic_PCB_software/App/Services/profile_storage.h
2026-04-24 16:51:15 +03:00

51 lines
2.0 KiB
C

/**
* @file profile_storage.h
* @brief Streamed SD-card writer for GUI-initiated profile saves.
*
* Architectural note:
* The desktop GUI already knows the current human-facing configuration values.
* It serialises them into the same INI/CSV text format that standalone boot
* understands, while this service owns the SD-card side: validating the
* profile name, generating 8.3-compatible file names, streaming incoming text
* into files, and updating `profiles.csv` only after the full upload succeeds.
*/
#ifndef PROFILE_STORAGE_H
#define PROFILE_STORAGE_H
#include <stdbool.h>
#include <stdint.h>
/**
* @brief Result codes returned by the streamed profile-save service.
*/
typedef enum profile_storage_status_t {
PROFILE_STORAGE_STATUS_OK = 0,
PROFILE_STORAGE_STATUS_INVALID_ARGUMENT,
PROFILE_STORAGE_STATUS_NAME_INVALID,
PROFILE_STORAGE_STATUS_STORAGE_UNAVAILABLE,
PROFILE_STORAGE_STATUS_SESSION_ACTIVE,
PROFILE_STORAGE_STATUS_NO_ACTIVE_SESSION,
PROFILE_STORAGE_STATUS_DIRECTORY_ERROR,
PROFILE_STORAGE_STATUS_FILE_NAME_EXHAUSTED,
PROFILE_STORAGE_STATUS_FILE_OPEN_ERROR,
PROFILE_STORAGE_STATUS_WRITE_ERROR,
PROFILE_STORAGE_STATUS_INDEX_UPDATE_ERROR,
PROFILE_STORAGE_STATUS_SIZE_MISMATCH,
PROFILE_STORAGE_STATUS_SECTION_ERROR
} profile_storage_status_t;
void profile_storage_init(void);
bool profile_storage_is_active(void);
profile_storage_status_t profile_storage_get_last_status(void);
profile_storage_status_t profile_storage_begin(const char *display_name,
uint16_t profile_text_bytes,
uint16_t waveform_text_bytes);
profile_storage_status_t profile_storage_write_chunk(uint16_t section_id,
const uint8_t *data,
uint16_t data_size);
profile_storage_status_t profile_storage_commit(void);
void profile_storage_cancel(void);
#endif /* PROFILE_STORAGE_H */