From 04b95840e106182266f71a549b85bcfff083deb1 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期五, 23 五月 2025 18:07:48 +0800
Subject: [PATCH] 成功测试完毕新的蓝牙和MK的传输协议,并实现读写功能

---
 keil/include/components/app/src/ranging_fira.c |   61 +++++++++---------------------
 1 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/keil/include/components/app/src/ranging_fira.c b/keil/include/components/app/src/ranging_fira.c
index 004015d..beb9436 100644
--- a/keil/include/components/app/src/ranging_fira.c
+++ b/keil/include/components/app/src/ranging_fira.c
@@ -136,16 +136,19 @@
 
 // This function will be called by uwbapi_session_init()
 void app_session_init(void)
-{
+{			
+	#ifdef MY_MODE
+			normal_uwb_change_to_fira();
+	#endif
     // register process handler for MAC TX done and RX done
     mac_register_process_handler(ranging_tx_process, ranging_rx_process);
+		uwbs_handler_init(&op);
 
-    uwbs_handler_init(&op);
 }
 
 void ranging_configure(void)
 {		
-		normal_uwb_change_to_fira();//变为fira配置的uwb
+		
     fira_keys_generate();
 
     aes_update_key(AES_ID0, &fira_key.devPayKey.ukey.keyByte[0]);
@@ -308,10 +311,10 @@
     .phy_cfg.rx_ant_id = UWB_RX_ANT_3,        /* UWB RX antenna port                       */
 };
 #endif
-uint8_t normal_flag;
+
 void uwb_fira_init(void)
 {
-		uwb_open();
+//		uwb_open();
 
     // set advanced parameters
     struct PHY_ADV_CONFIG_T adv_config =
@@ -339,53 +342,23 @@
     uwb_app_config.session_param.tx_power_level = board_param.tx_power_fcc[CALIB_CH(uwb_app_config.ppdu_params.ch_num)];
     uwb_app_config.ppdu_params.rx_ant_id = (uint8_t)(RX_MAIN_ANT_PORT);
 }
+uint8_t normal_flag=0;
 void uwb_normal_init(void)
 {
- // The following peripherals will be initialized in the uwb_open function
-    // phy/mac/aes/lsp/phy timers initialized
-			uwb_open();
-#ifdef STS_MODE
-	   // Set STS key and IV
-    phy_sts_key_configure(&sts_iv_key);
-#endif
-    // Set calibration parameters
-    uwb_calibration_params_set(config.phy_cfg.ch_num);
-#ifdef STS_MODE
-	
-	 // set advanced parameters
-    struct PHY_ADV_CONFIG_T adv_config = {
-        .thres_fap_detect = 40,
-        .nth_scale_factor = 4,
-        .ranging_performance_mode = 3,
-        .skip_weakest_port_en = 0,
-    };
-#else
-    // set advanced parameters
-     struct PHY_ADV_CONFIG_T adv_config = {
-        .thres_fap_detect = 40,
-        .nth_scale_factor = 4,
-        .ranging_performance_mode = 0,
-        .skip_weakest_port_en = 0,
-    };
-#endif
-    phy_adv_params_configure(&adv_config);
-
-    // uwb configure
-    uwb_configure(config.phy_work_mode, board_param.tx_power_fcc[CALIB_CH(config.phy_cfg.ch_num)], &config.phy_cfg);
-#if (defined STS_MODE) || (defined MK_MODE)
-		ranging_lib_init();
-#endif
-    ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg);
+Uwb_init();	
 }
 void fira_uwb_change_to_normal(void)
 {
-uwb_close();
+//uwb_close();
+	CloseUWB();
 uwb_normal_init();
+	OpenUWB();
 normal_flag=1;	
 }
-void normal_uwb_change_to_fira(void)
+void normal_uwb_change_to_fira(void)//少个回调设置
 {
-uwb_close();
+//uwb_close();
+	CloseUWB();
 uwb_fira_init();
 normal_flag=0;
 }
@@ -433,7 +406,9 @@
 void ranging_stop(void)
 {
     ranging_env.enable = 0;
+	#ifdef MY_MODE
 		fira_uwb_change_to_normal();//变为normal配置的uwb
+	#endif
     ranging_monitor_stop();
     LOG_INFO(TRACE_NO_REPORT_HOST | TRACE_MODULE_APP, "Ranging stop\r\n");
 }

--
Gitblit v1.9.3