From 147d2248cd39e7686e73313ef5408fda066fdb0a Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期二, 27 八月 2019 21:09:00 +0800
Subject: [PATCH] 增加标签确定序号

---
 源码/核心板/Src/application/dw_app.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
index 643eb8b..2a911aa 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
@@ -73,7 +73,7 @@
 #define ANC_TYPE_IDX 					14
 #define BATTARY_IDX						15
 #define BUTTON_IDX						16
-
+#define SEQUENCE_IDX					17
 //respose
 #define TIMECORRE             14
 
@@ -97,7 +97,7 @@
 };
 
 /* Frames used in the ranging process. See NOTE 2 below. */
-static uint8_t tx_poll_msg[19] = {0};
+static uint8_t tx_poll_msg[20] = {0};
 //static uint8_t rx_resp_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'V', 'E', 'W', 'A', 0x10, 0x02, 0, 0, 0, 0};
 static uint8_t tx_final_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'W', 'A', 'V', 'E', 0x23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 	
@@ -295,7 +295,7 @@
 uint16_t g_Resttimer;
 uint8_t result;
 u8 tag_succ_times=0;
-u32 hex_dist;
+int32_t hex_dist;
 u16 checksum;
 int8_t tag_delaytime;
 void Tag_App(void)//发送模式(TAG标签)
@@ -312,6 +312,7 @@
 	tag_succ_times = 0;
 	tx_poll_msg[BATTARY_IDX] = Get_Battary();
 	tx_poll_msg[BUTTON_IDX] = !READ_KEY0;
+	tx_poll_msg[SEQUENCE_IDX] = frame_seq_nb++;
 
 	for(i=0;i<g_com_map[MAX_REPORT_ANC_NUM];i++)
 	{
@@ -395,7 +396,7 @@
 					
 					usart_send[2] = 1;//正常模式
 					usart_send[3] = 17;//数据段长度
-					usart_send[4] = frame_seq_nb++;//数据段长度
+					usart_send[4] = frame_seq_nb;//数据段长度
 					memcpy(&usart_send[5],&dev_id,2);
 					memcpy(&usart_send[7],&rx_buffer[ANCHOR_ID_IDX],2);
 					hex_dist = anchor_dist_last_frm[0];;
@@ -488,7 +489,7 @@
 		
 		if (rx_buffer[MESSAGE_TYPE_IDX] == POLL&&(anchor_type == rx_buffer[ANC_TYPE_IDX])) //判断是否是poll包数据
 		{
-			correction_time=tag_timer-(tag_id_recv%GROUP_TAG_NUM)*3;
+			correction_time=tag_timer-tag_id_recv*3;
 							if(correction_time == g_com_map[COM_INTERVAL])
 								correction_time = 0;
 								tx_resp_msg[TIMECORRE] = correction_time;
@@ -516,6 +517,7 @@
 
 			battary = rx_buffer[BATTARY_IDX];
 			button = rx_buffer[BUTTON_IDX];
+			frame_seq_nb = rx_buffer[SEQUENCE_IDX];
 			/* We assume that the transmission is achieved correctly, now poll for reception of expected "final" frame or error/timeout.
 			 * See NOTE 7 below. */
 			if(result==0)
@@ -587,10 +589,10 @@
 						
 					usart_send[2] = 1;//正常模式
 					usart_send[3] = 17;//数据段长度
-					usart_send[4] = frame_seq_nb++;//数据段长度
+					usart_send[4] = frame_seq_nb;//数据段长度
 					memcpy(&usart_send[5],&tag_id_recv,2);
 					memcpy(&usart_send[7],&dev_id,2);
-					hex_dist = dist_cm;
+					
 					memcpy(&usart_send[9],&hex_dist,4);
 					usart_send[13] = battary;
 					usart_send[14] = button;

--
Gitblit v1.9.3