Files
99_7018_lmx/apps/earphone/xtell_remote_control/nvs/nvs.h
2025-12-10 17:40:26 +08:00

58 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __NVS_H__
#define __NVS_H__
#include "typedef.h"
#include "../task_func.h"
#define MAIN_BOARD_MAC_ADDR_LENGTH UID_LENGTH
/**
* @brief 定义用于存储遥控器配对信息的数据结构
*/
typedef struct {
u8 main_board_mac[MAIN_BOARD_MAC_ADDR_LENGTH]; // 配对的主板MAC地址
// u8 reserved[2]; // 可选的保留字节,用于对齐或未来扩展
} rc_nvs_data_t;
/**
* @brief 将主板MAC地址写入Flash
*
* @param mac_addr 指向要写入的MAC地址数组的指针
* @return 实际写入的长度, <0: 失败
*/
int nvs_write_main_board_mac(const u8 *mac_addr);
/**
* @brief 从Flash读取主板MAC地址
*
* @param mac_addr 指向用于存储读取数据的MAC地址数组的指针
* @return 实际读取的长度, <0: 失败 (例如尚未写入过)
*/
int nvs_read_main_board_mac(u8 *mac_addr);
int nvs_clear_info(void);
// =================================================================================
// 以下为旧的通用出厂信息API已废弃不建议在新代码中使用
// =================================================================================
typedef struct {
char product_id[16];
char serial_number[32];
u16 hw_version;
u16 cal_data;
u32 manufacture_date;
} factory_info_t;
__attribute__((deprecated("Use nvs_write_main_board_mac instead")))
int nvs_write_factory_info(const factory_info_t *info);
__attribute__((deprecated("Use nvs_read_main_board_mac instead")))
int nvs_read_factory_info(factory_info_t *info);
__attribute__((deprecated("This function is no longer needed")))
int nvs_clear_factory_info(void);
__attribute__((deprecated("This function is no longer needed")))
void nvs_test_factory_info(void);
#endif // __NVS_H__