This commit is contained in:
lmx
2025-12-10 17:40:26 +08:00
parent 23b14f0142
commit 141b538bf5
9 changed files with 51 additions and 17 deletions

View File

@ -32,8 +32,8 @@
// IIC配置 //
//*********************************************************************************//
/*软件IIC设置*/ //xtell
#define TCFG_SW_I2C0_CLK_PORT IO_PORTB_04 //软件IIC CLK脚选择 XTELL
#define TCFG_SW_I2C0_DAT_PORT IO_PORTB_05 //软件IIC DAT脚选择
#define TCFG_SW_I2C0_CLK_PORT IO_PORTA_05//IO_PORTB_04 //软件IIC CLK脚选择 XTELL
#define TCFG_SW_I2C0_DAT_PORT IO_PORTA_06//IO_PORTB_05 //软件IIC DAT脚选择
#define TCFG_SW_I2C0_DELAY_CNT 0 //IIC延时参数影响通讯时钟频率
/*硬件IIC端口选择 -- 具体看手册,这里写的不准 -- lmx
@ -44,7 +44,6 @@
'D': IO_PORTA_05 IO_PORTA_06
具体要选择哪个iic口去board_jl701n_demo.c中设置hw_iic_cfg
*/
#define TCFG_HW_I2C0_PORTS 'B'
#define TCFG_HW_I2C0_CLK 100000

View File

@ -3,8 +3,8 @@
#include "nvs.h"
// 2. 定义唯一的配置项ID
#define CFG_FACTORY_INFO_ID 10 // 旧的、通用的出厂信息ID (已废弃)
#define CFG_RC_MAC_ADDR_ID 11 // 新的、专门用于存储遥控器配对MAC的ID
#define CFG_RC_MAC_ADDR_ID 11 // 配置项id
/**
* @brief 将主板MAC地址写入Flash
@ -53,10 +53,32 @@ int nvs_read_main_board_mac(u8 *mac_addr)
return ret;
}
/**
* @brief 清空Flash中的出厂信息
*
* @return 0: 成功, <0: 失败
*/
int nvs_clear_info(void)
{
rc_nvs_data_t nvs_data;
for(int i = 0 ; i < MAIN_BOARD_MAC_ADDR_LENGTH; i++){
nvs_data.main_board_mac[i] = 0;
}
printf("--> Clearing factory info from flash...\n");
// 写入长度为0的数据即可实现删除效果
int ret = syscfg_write(CFG_RC_MAC_ADDR_ID, &nvs_data, sizeof(rc_nvs_data_t));
if (ret != 0) {
printf("!!! syscfg_write clear factory info failed, ret = %d\n", ret);
} else {
printf("--> syscfg_write clear factory info success.\n");
}
return ret;
}
// =================================================================================
// 以下为旧的通用出厂信息API已废弃
// =================================================================================
#define CFG_FACTORY_INFO_ID 10 // 旧的、通用的出厂信息ID (已废弃)
int nvs_write_factory_info(const factory_info_t *info)
{
printf("WARNING: nvs_write_factory_info is deprecated.\n");

View File

@ -30,7 +30,7 @@ int nvs_write_main_board_mac(const u8 *mac_addr);
*/
int nvs_read_main_board_mac(u8 *mac_addr);
int nvs_clear_info(void);
// =================================================================================
// 以下为旧的通用出厂信息API已废弃不建议在新代码中使用
// =================================================================================

View File

@ -93,18 +93,19 @@ void rc_rfid_callback_handler(void *priv)
// memset(current_board_mac, uid, sizeof(current_board_mac));
// TODO发送指令让主板断开经典蓝牙连接
// TODO: 切断BLE
// g_ble_connect_new_device(current_board_mac); //连接新主板
// 重新启动扫描,以连接到新的主板
// EARPHONE_STATE_SET_PAGE_SCAN_ENABLE();
break;
case RFID_DEVICE_TYPE_REMOTE_CONTROL:
case RFID_DEVICE_TYPE_REMOTE_CONTROL: //扫的是遥控器
rc_log("Device is another Remote Control.\n");
if(g_rc_context.team != TEAM_YES){
nvs_clear_info(); //清楚nfc数据
return; //非组队状态
}
if (g_ble_get_state() == BLE_ST_NOTIFY_IDICATE) {
rc_log("Sending teaming request to main board...\n");
//TODO:
@ -249,6 +250,8 @@ void rc_app_main_init(void)
// 1. 初始化全局上下文
memset(&g_rc_context, 0, sizeof(RC_Context_t));
g_rc_context.state = RC_STATE_DISCONNECTED; // 初始状态为未连接
g_rc_context.team = TEAM_NO;
FM176XX_HardInit();
// 2. 检查并启动RFID处理定时器
if (g_rfid_timer_id == 0) {
@ -268,16 +271,18 @@ void rc_app_main_init(void)
//test
#define TEST_FUNCTION 1
void test_task(void){
#if TEST_FUNCTION == 1
FM176XX_HardInit();
while(1){
u8 uid[UID_LENGTH] = {0};
//读id卡
TYPE_V_EVENT((char *)uid);
// TYPE_A_EVENT((char *)uid);
os_time_dly(10);
os_time_dly(100);
}
#endif
}
void test_func_main(void){

View File

@ -31,6 +31,14 @@ typedef enum {
RC_STATE_CONNECTED, // 已连接主板
} RC_State_t;
/**
* @brief 当前是否处于组队状态
*/
typedef enum {
TEAM_NO, //未组队
TEAM_YES,
} RC_State_t;
/**
* @brief RFID读取到的设备类型
*/
@ -45,6 +53,7 @@ typedef enum {
*/
typedef struct {
RC_State_t state; // 当前状态机状态
RC_State_t team; //当前是否组队
u8 paired_mac_addr[UID_LENGTH]; // 已配对主板的MAC地址(包含前缀)
// ... 可在此处添加更多运行时需要管理的数据
} RC_Context_t;

Binary file not shown.

Binary file not shown.

View File

@ -5224,7 +5224,6 @@ objs/apps/earphone/xtell_remote_control/ble_handler/ble_test.c.o
objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_get_client_operation_table,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_profile_init,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,printf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,le_device_db_init,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_stack_gatt_role,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,gatt_client_init,l
@ -5245,17 +5244,17 @@ objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,bt_get_mac_addr,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,g_ble_connect_new_device,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,g_ble_get_state,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,put_buf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,usr_timer_add,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,sys_timeout_del,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,syscfg_read,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,syscfg_write,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,little_endian_read_16,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,printf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,put_buf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,memcmp,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_init,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_set_search_complete,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,sys_timer_add,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_vendor_get_peer_rssi,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,client_user_target,pl
objs/apps/earphone/xtell_remote_control/ble_handler/example/example.c.o
objs/apps/earphone/xtell_remote_control/nvs/nvs.c.o