File upload. Yeah

This commit is contained in:
2026-03-17 15:02:34 +01:00
parent 6ec66cd9da
commit 574ab9fa30
19 changed files with 1479 additions and 250 deletions

View File

@@ -2,25 +2,41 @@
#define FS_MGMT_H
#include <zephyr/fs/fs.h>
#include "buzz_proto.h"
#define FS_MGMT_MAX_PATH_LENGTH 32
#define FS_AUDIO_PATH CONFIG_FS_MGMT_MOUNT_POINT "/a"
#define FS_SYSTEM_PATH CONFIG_FS_MGMT_MOUNT_POINT "/sys"
#define FS_AUDIO_PATH CONFIG_FS_MGMT_MOUNT_POINT CONFIG_FS_MGMT_AUDIO_SUBDIR
#define FS_SYSTEM_PATH CONFIG_FS_MGMT_MOUNT_POINT CONFIG_FS_MGMT_SYSTEM_SUBDIR
/**
* @brief Initializes the filesystem management module.
*/
int fs_mgmt_init(void);
// /**
// * @brief Puts the QSPI flash into deep sleep mode to save power
// */
// int fs_pm_flash_suspend(void);
// /**
// * @brief Resumes the QSPI flash from deep sleep mode
// */
// int fs_pm_flash_resume(void);
/**
* @brief OP-Codes for the FS write thread
*/
enum fs_write_op {
FS_WRITE_OP_FILE_START,
FS_WRITE_OP_FILE_CHUNK,
FS_WRITE_OP_FILE_END,
FS_WRITE_OP_TAGS_START, // Schon mal vorgesehen
FS_WRITE_OP_FW_START, // Schon mal vorgesehen
FS_WRITE_OP_ABORT
};
/**
* @brief Structure representing a write message for the FS write thread
*/
struct fs_write_msg {
enum fs_write_op op;
uint8_t *slab_ptr; /* Basis-Pointer des Memory-Slabs (für k_mem_slab_free) */
uint16_t data_offset; /* Offset ab dem slab_ptr, wo die Nutzdaten beginnen */
uint16_t data_len; /* Länge der Nutzdaten */
uint32_t metadata; /* Zusatzinfo (Start: erwartete Dateigröße, End: erwartete CRC32) */
buzz_transport_reply_fn reply_cb; /* Callback für ACKs / Success / Error */
};
/**
* @brief Wrapper around fs_open that handles power management for the flash
@@ -114,4 +130,18 @@ int fs_mgmt_pm_mkdir_recursive(char *path);
*/
int fs_mgmt_pm_rm_recursive(char *path, size_t max_len);
/**
* @brief Gets the length of the audio data in a file, accounting for any metadata tags, ensuring the flash is active during the operation
* @param fp Pointer to an open fs_file_t structure representing the file
* @return Length of the audio data on success, negative error code on failure
*/
ssize_t fs_get_audio_data_len(struct fs_file_t *fp);
/**
* @brief Submits a write message to the FS write thread, which will handle writing data to the filestem asynchronously, ensuring the flash is active during the operation
* @param msg Pointer to the fs_write_msg structure containing the write operation details
* @return 0 on success, negative error code on failure
*/
int fs_mgmt_submit_write(struct fs_write_msg *msg);
#endif /* FS_MGMT_H */