From 1e1b1b9f73152b17b960c5c2b1531d66ca4ddbe0 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期一, 26 五月 2025 18:15:11 +0800
Subject: [PATCH] 移植完新版lora和新版测距代码,lora传输有问题未解决

---
 keil/include/drivers/uwb_app.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/keil/include/drivers/uwb_app.c b/keil/include/drivers/uwb_app.c
index bf2bb11..315abe6 100644
--- a/keil/include/drivers/uwb_app.c
+++ b/keil/include/drivers/uwb_app.c
@@ -50,6 +50,7 @@
 static uint16_t tagid_list[TAG_NUM_IN_SYS];
 uint16_t CmpTagInList(uint16_t tagid);
 uint8_t Anchor_RecNearPoll(uint8_t ancrec_nearbasepos);
+uint8_t report_ancnum;
 static uint8_t send_buffer[100];
 static uint8_t tagofflinetime[TAG_NUM_IN_SYS];
 uint32_t temp_count=0;
@@ -280,7 +281,7 @@
 /* RX done process handler. */
 int8_t rssi;
 uint32_t range_timeout_us = 2000000;//yuan5000
-uint8_t flag_temp2,flag_temp1;
+uint8_t flag_temp2,flag_temp1,resp_tx_flag;
 uint16_t uwb_losttimer;
 static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report)
 {		uint8_t valid_sts=0;
@@ -289,7 +290,7 @@
 
     /** UWB RX success */
     if (rx_report->err_code == UWB_RX_OK)
-    {
+    {		resp_tx_flag=0;
         /* Received data does not contain FCS */
         rx_length = rx_report->pkt_len;
         memcpy(rx_buf, rx_report->pkt_data, rx_length);
@@ -302,6 +303,10 @@
         rssi = rx_report->rssi;
         receive_flag=1;
 				Anchor_App();
+			if(resp_tx_flag==0)
+			{
+			  OpenUWB();
+			}
 			#ifdef STS_MODE
 				valid_sts= sts_valid_check();
       if (valid_sts)
@@ -329,9 +334,9 @@
 			        temp_count= phy_timer_count_get();
         memcpy(&rx_rpt, rx_report, sizeof(struct MAC_HW_REPORT_T));
         rx_length = 0;
-			//	OpenUWB();//再次开启UWB接收
+				OpenUWB();//再次开启UWB接收
     }
-	OpenUWB();//再次开启UWB接收
+	//OpenUWB();//再次开启UWB接收
 }
 
 /* TX done process handler. */
@@ -345,6 +350,7 @@
     {
         temp_count= phy_timer_count_get();
         temp_internal=temp_count;
+				OpenUWB();
         resp_tx_num++;
 		//		OpenUWB();//再次开启UWB接收
         //LOG_INFO(TRACE_MODULE_APP, "poll_rx_num is %d,resp_tx_num is %d\r\n",poll_rx_num,resp_tx_num);
@@ -460,11 +466,18 @@
 //    }
 //    anchordata_num=j;
 //}
+uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM];
 void TagListUpdate(void)
 {
 uint16_t i,j=0,k=0;
     for(i=0; i<taglist_num; i++)
-    {
+    {		
+			
+			if(tagofflinetime[i]<REPORT_TAG_KEEPTIMES)
+        {
+            report_ancid[k]=tagid_list[i];
+            report_ancdist[k++]=(uint16_t)tagdist_list[i];
+        }
 			 if(tagofflinetime[i]++<TAG_KEEPTIMES)
         {
             tagid_list[j]=tagid_list[i];
@@ -473,6 +486,7 @@
             tagofflinetime[j++]=tagofflinetime[i];
         }
 		}
+			report_ancnum = k;
 		 taglist_num=j;
 }
 
@@ -508,6 +522,7 @@
     temp_resp_i64=resp_tx_ts_i64;
     temp_count3= phy_timer_count_get();
     flag_temp2=uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小
+		resp_tx_flag=1;//限制重复开启
 		tagofflinetime[taglist_pos] = 0;//更新标签通信
 //    temp_count1=phy_timer_count_get();
     //while(mac_is_busy());
@@ -528,8 +543,11 @@
 enumwltagstate wltag_state=RANGE;
 uint32_t wltag_statetimer,wltag_uwbtimer;
 uint32_t uwbtasktimer=0,uwbtagsendtimer=0;
+uint8_t report_ancnum;
+uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM];
 void IdleTask(void)
 {UART_CheckReceive();
+	UART0_CheckReceive();
 //if(read_5v_input_pca())
 //		{
 //		        if(state5v==0)
@@ -583,7 +601,7 @@
 		if(secondtask_search_flag)//更新S时间TICK
 		{
 		HIDO_TimerTick();
-		TagListUpdate();
+		//TagListUpdate();
 //    GPS_Poll();
 //		if(nomove_count<=g_com_map[NOMOVESLEEP_TIME])//防止溢出
 //    nomove_count++;

--
Gitblit v1.9.3