From d9a7770ba94decb726583ab824fe5fb0d0b4d85f Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期三, 01 七月 2020 20:36:10 +0800
Subject: [PATCH] 远程修改标签配置功能,好像有bug,map表会自动修改

---
 源码/核心板/Src/application/dw_app.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 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 53978d4..33a51d4 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"
@@ -784,6 +784,7 @@
 u8 misdist_num[TAG_NUM_IN_SYS],seize_anchor;
 u8 Anchor_RecNearPoll(u8 ancrec_nearbasepos) //0 mainbase  1 first near_base
 {
+	u8 motorstate;
 			tmp_time=TIM3->CNT;
 			memcpy(&tx_nearresp_msg[ANCTIMEMS],&sync_timer,2);
 			memcpy(&tx_nearresp_msg[ANCTIMEUS],&tmp_time,2);
@@ -795,7 +796,20 @@
 			dwt_setdelayedtrxtime(resp_tx_time);//设置Response发送时间T3
 			dwt_setrxaftertxdelay(RESP_TX_TO_FINAL_RX_DLY_UUS+(rec_nearbase_num+1-ancrec_nearbasepos)*DELAY_BETWEEN_TWO_FRAME_UUS);//设置发送完成后开启接收延迟时间
 			dwt_setrxtimeout(FINAL_RX_TIMEOUT_UUS);//接收超时时间
-
+			
+			if(tagdist_list[taglist_pos]<g_com_map[ALARM_DISTANCE1])
+			{
+				motorstate =3;
+			}else if(tagdist_list[taglist_pos]<g_com_map[ALARM_DISTANCE2])
+			{
+				motorstate =2;
+			}else if(tagdist_list[taglist_pos]<g_com_map[ALARM_DISTANCE3])
+			{
+				motorstate =1;
+			}else{
+				motorstate =0;
+			}
+			
 			if(new_tagid)
 			{
 				tagdist_list[taglist_pos]=0x1ffff;
@@ -805,9 +819,16 @@
 			}
 			tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase;
 			tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE;
-			
-			dwt_writetxdata(21, tx_nearresp_msg, 0);//写入发送数据
-			dwt_writetxfctrl(21, 0);//设定发送长度
+			tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate;
+			if(remotesend_state)
+			{
+			 	memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,REMOTEPARA_LEN);
+				dwt_writetxdata(22+REMOTEPARA_LEN, tx_nearresp_msg, 0);//写入发送数据
+				dwt_writetxfctrl(22+REMOTEPARA_LEN, 0);//设定发送长度		
+			}else{
+			dwt_writetxdata(22, tx_nearresp_msg, 0);//写入发送数据
+			dwt_writetxfctrl(22, 0);//设定发送长度
+			}
 			result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
 
 			battary = rx_buffer[BATTARY_IDX];
@@ -871,7 +892,7 @@
 					his_dist[taglist_pos]=hex_dist;	
 						g_Tagdist[taglist_pos]=hex_dist;	
 				#ifndef USART_INTEGRATE_OUTPUT
-					usart_send[2] = 1;//正常模式
+					usart_send[2] = 1;//正常模式 
 					usart_send[3] = 17;//数据段长度
 					usart_send[4] = frame_seq_nb;//数据段长度
 					memcpy(&usart_send[5],&tag_id_recv,2);

--
Gitblit v1.9.3