From cf92a2fedf94d889b1a39e8557221149ea554a3c Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期五, 19 五月 2023 14:30:44 +0800
Subject: [PATCH] v2.8

---
 Src/application/dw_app.c |   53 +++++++++++++++++++++++++----------------------------
 1 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index aa689a3..74ca7f5 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -471,7 +471,7 @@
 u8 nearbase_num=0,last_nearbase_num,next_nearbase_num,last_slotnum, para_update,para_len,stationary_flag=0;
 u32 rec_tagpos_binary;
 int16_t offset=4700,temptimer;
-u8 motor_state,rec_remotepara_state,rec_remotepara[80];
+static u8 motor_state,rec_remotepara_state,rec_remotepara[80];
 
 
 #define SINGLEPOLL_BASENUM 5
@@ -648,9 +648,9 @@
         temptime = (slotpos_intoatl*SLOTTIME_MS+100)*100;
         if(anchor_time<temptime-5000)
         { 
-					current_slotnum = pd_i;
+            current_slotnum = pd_i;
             delaytime = temptime-anchor_time+poll_offsettime+clockoffset;  
-						expect_anctime = temptime;
+            expect_anctime = temptime;
             return ;
         }
     }
@@ -668,14 +668,14 @@
     NextPollDelay(anchor_time);
     current_count=HAL_LPTIM_ReadCounter(&hlptim1);
     lpcount = current_count+delaytime/LPTIMER_LSB+(10-nearbase_num)*8;
-		poll_startcount = lpcount+(waketopolltimeus)/LPTIMER_LSB;
+    poll_startcount = lpcount+(waketopolltimeus)/LPTIMER_LSB;
 		if(poll_startcount>=32768)
 		{
-		poll_startcount -=32768;
+            poll_startcount -=32768;
 		}
 		if(lpcount>=32768)
 		{
-		lpcount -=32768;
+            lpcount -=32768;
 		}
     __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount);
 		last_lpcount = lpcount;
@@ -691,11 +691,11 @@
 	}else{
 		lpcount = last_lpcount+31457/tag_frequency+32.767*delayms;//(float)(200/tag_frequency*48+delayms*10)*3.3 ;
 	}
-				if(lpcount>=32768)
-				{
-				lpcount -=32768;
-				}		
-				poll_startcount = lpcount+(waketopolltimeus)/LPTIMER_LSB;
+    if(lpcount>=32768)
+    {
+    lpcount -=32768;
+    }		
+    poll_startcount = lpcount+(waketopolltimeus)/LPTIMER_LSB;
 		if(poll_startcount>=32768)
 		{
 		poll_startcount -=32768;
@@ -763,6 +763,8 @@
             tagpoll_sync_sec = current_slotpos/200;
             tagslotpos = current_slotpos%200;
             max_slotpos = rec_tagperiod*20;
+            tag_frequency = 10/rec_tagperiod;
+            bigslot_num = TOTAL_SLOTNUM/tag_frequency;
 			tag_state=NEARPOLL;
 		}
 	}else{
@@ -836,7 +838,7 @@
     memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*2],&nearbase_distlist,nearbase_num*4+4);
     memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*6+4],&rec_anc_signalpower,nearbase_num*2+2);
     
-    
+    userkey_state = 0;
     if(intheight!=0)
     intheight+=g_com_map[HEIGHTOFFEST_INDEX];
     
@@ -953,7 +955,7 @@
 									dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
 									dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5
 									result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送	
-									userkey_state = !GET_USERKEY;
+								//	userkey_state = !GET_USERKEY;
 
 									memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
                                     if(temp_dist!=nearbase_distlist[0])
@@ -1084,11 +1086,11 @@
 			}	
 			if(mainbase_lost_count!=0)
 			{
-//				if(mainbase_lost_count<=tag_frequency*1)
-//				{NextSlotDelayMs(0);
-//				}else{
-//					NextSlotDelayMs(0);
-//				}
+				if(mainbase_lost_count<=tag_frequency*1)
+				{NextSlotDelayMs(0);
+				}else{
+					NextSlotDelayMs(0);
+				}
 			}	
 
 			if(para_update)
@@ -1159,7 +1161,7 @@
 {
 	static u8 regpoll_count=0;
 	mainbase_lost_count = 0;
-		tag_frequency = REGISTER_FREQUENCY;
+		//tag_frequency = REGISTER_FREQUENCY;
 		bigslot_num = TOTAL_SLOTNUM/tag_frequency;
 		regpoll_count++;
 		if(regpoll_count%2)
@@ -1251,15 +1253,12 @@
     }
     error_times = 0;
 }
+
 void Tag_App(void)//发送模式(TAG标签)
 {
 	static uint8_t diccount = 0,diccount2;
 	//LED0_ON;
     UWBWkWp();
-            if(0)
-        {
-             FZNearPoll();
-        }else{
 	switch(tag_state)
 	{
 		case REGPOLL:
@@ -1303,11 +1302,9 @@
         case SINGLEPOLL:
           //  Poll();
             break;
-	}}
-        
- FZNearPoll();
-
+	}       
+    FZNearPoll();
     dwt_forcetrxoff();
-     userkey_state = !GET_USERKEY;
+//    userkey_state = !GET_USERKEY;
 	dwt_entersleep();
 }

--
Gitblit v1.9.3