From cdcf6a128503b3a4fc0dcc4f86ec63a3ab8a59b5 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期三, 09 十二月 2020 21:42:40 +0800
Subject: [PATCH] V2.13 修改丢包重连机制

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

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 08c29a5..6d6e1a9 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -69,7 +69,7 @@
 #define FINAL_MSG_FINAL_TX_TS_IDX 18
 #define FINAL_MSG_TS_LEN 4
 
-#define STARTPOLL  DISCPOLL
+#define STARTPOLL  REGPOLL
 enum enumtagstate
 {
 	REGPOLL,
@@ -552,7 +552,7 @@
 			{
 				memcpy(&minid, &rx_buffer[ANCHOR_ID_IDX], 4);
 				tag_state=GETNEARMSG;
-				trygetnearmsg_times=5;
+				trygetnearmsg_times=10*tag_frequency;
 				mindist=temp_dist;
 			}
 			if(result==0)
@@ -576,7 +576,7 @@
 }
 	if(getsync_flag==0)
 	{
-	tagslotpos--;
+//	tagslotpos--;
 			if(tagslotpos==0||tagslotpos>max_slotpos)
 		{		
 			tagslotpos=max_slotpos;	
@@ -628,7 +628,7 @@
 			tag_state=NEARPOLL;
 		}
 	}else{
-			tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;
+//			tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;
 	}
 }
 extern u8 userkey_state;
@@ -777,7 +777,7 @@
 									memcpy(&nearbase_switchdistlist[rec_nearbasepos],&rx_buffer[NR_NEARSWITCH_DISTANCE],2);
 									nearbase_distlist[rec_nearbasepos]=temp_dist;								
 									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts);
-									if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist!=0)
+									if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist>0)
 									{
 										mainbase_id = rec_nearbaseid;
 										tag_state = GETNEARMSG;
@@ -799,10 +799,10 @@
 			dwt_forcetrxoff();
 dwt_write32bitreg(SYS_STATUS_ID,SYS_STATUS_RXFCG| SYS_STATUS_ALL_RX_ERR);
 		j=0;
-			if(exsistbase_list[0]==0)
-			{
+//			if(exsistbase_list[0]==0)
+//			{
 //				SetNextPollTime(tagslotpos);
-			}
+//			}
 		//	tyncpoll_time=0;
 //			next_nearbase_num=0;
 //			for(i=0;i<nearbase_num;i++)
@@ -852,10 +852,10 @@
 //				mainbase_id = true_nearbase_idlist[0];
 //				tag_state = GETNEARMSG;
 //			}
-//			if(mainbase_lost_count>3)
-//			{
-//				tag_state = DISCPOLL;
-//			}
+			if(mainbase_lost_count>10*tag_frequency)
+			{
+				tag_state = STARTPOLL;
+			}
 //				for (i=0;i<nearbase_num;i++)
 //	{
 //		if(nearbaseid_list[i]==0)
@@ -988,7 +988,7 @@
 	id =  dwt_readdevid() ;
 	    while (DWT_DEVICE_ID != id) 
     {
-			Dw1000_Init();
+		//	Dw1000_Init();
 			id =  dwt_readdevid() ;
     }
 	switch(tag_state)
@@ -1010,7 +1010,7 @@
 		LED_LG_OFF;
 		if(trygetnearmsg_times==0)
 		{
-			tag_state = DISCPOLL;
+			tag_state = STARTPOLL;
 		}
 			break;
 		case NEARPOLL:

--
Gitblit v1.9.3