From fe3d62872399777355b61ff1eb0a1a2e8ad02fed Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 27 七月 2023 11:59:41 +0800 Subject: [PATCH] 版本v2.3,加入用户传输2个字节的输出。 --- Src/application/dw_app.c | 48 ++++++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index c8aceda..861e053 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -29,7 +29,7 @@ #include <stdio.h> #include "beep.h" #include "modbus.h" - +#include "BMP390.h" /*------------------------------------ Marcos ------------------------------------------*/ /* Inter-ranging delay period, in milliseconds. */ #define RNG_DELAY_MS 100 @@ -81,7 +81,7 @@ SINGLEPOLL, }tag_state=STARTPOLL; dwt_config_t config = { - 2, /* Channel number. */ + 5, /* Channel number. */ DWT_PRF_64M, /* Pulse repetition frequency. */ DWT_PLEN_128, /* Preamble length. */ DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ @@ -118,7 +118,7 @@ LPFilter_Frac* p_Dis_Filter; //测距用的低通滤波器 - +void GetNearMsg(void); static uint64_t get_tx_timestamp_u64(void) { uint8_t ts_tab[5]; @@ -185,6 +185,7 @@ /* Apply default antenna delay value. See NOTE 1 below. */ dwt_setrxantennadelay(RX_ANT_DLY); //设置接收天线延迟 dwt_settxantennadelay(TX_ANT_DLY); //设置发射天线延迟 + /* Set expected response's delay and timeout. See NOTE 4 and 5 below. * As this example only handles one incoming frame with always the same delay and timeout, those values can be set here once for all. */ //设置接收超时时间 @@ -609,8 +610,9 @@ if(minddist!=0x1ffff&&minddist!=0) { trygetnearmsg_times = 0; - tag_state = GETNEARMSG; + tag_state = GETNEARMSG; mainbase_id = mindist_ancid; + GetNearMsg(); } if(getsync_flag==0) @@ -1054,18 +1056,18 @@ } nearbase_distlist[rec_nearbasepos+1]=temp_dist; // nearbase_distlist[1]对应 rec_nearbaseid[0]的距离 final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts); - if(temp_dist<salvebase_mindist&&nearbase_switchdistlist[rec_nearbasepos]==1) + if(temp_dist<salvebase_mindist&&nearbase_switchdistlist[rec_nearbasepos]!=0&&(nearbase_switchdistlist[rec_nearbasepos]==1||temp_dist<nearbase_switchdistlist[rec_nearbasepos])) { salvebase_mindist = temp_dist; mindist_slavebaseid = rec_nearbaseid; } #ifdef SWITCHBASE_ZHUANDIAN - if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]>1&&temp_dist>0) - { - mainbase_id = rec_nearbaseid; - tag_state = GETNEARMSG; - trygetnearmsg_times = 0; - } +// if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]>1&&temp_dist>0) +// { +// mainbase_id = rec_nearbaseid; +// tag_state = GETNEARMSG; +// trygetnearmsg_times = 0; +// } #endif } @@ -1093,23 +1095,27 @@ if(salvebase_mindist<mainbase_dist- THRESHOLD_CHANGE_MAINBASE_DIST ) { changemainbase_count++; - if(changemainbase_count>tag_frequency*2) + if(changemainbase_count>2) { - mainbase_id = mindist_slavebaseid; - tag_state = GETNEARMSG; - trygetnearmsg_times = 0; + changemainbase_count = 0; + mainbase_id = mindist_slavebaseid; + tag_state = GETNEARMSG; + trygetnearmsg_times = 0; + GetNearMsg(); } }else{ changemainbase_count = 0; } #endif - }else if(mainbase_lost_count>5*tag_frequency) + }else if(mainbase_lost_count>10) { + mainbase_lost_count = 0; tag_state = DISCPOLL; + DiscPoll(); } if(mainbase_lost_count!=0) { - if(mainbase_lost_count<=tag_frequency*1) + if(mainbase_lost_count<=5) {NextSlotDelayMs(0); }else{ NextSlotDelayMs(0); @@ -1166,6 +1172,7 @@ if(nearbaseid_list[i]!=nearbaseid_list2[i]) { tag_state = GETNEARMSG; + GetNearMsg(); trygetnearmsg_times = 0; nearbaseid_list0[i]=1; } @@ -1262,8 +1269,8 @@ } } u32 id,error_times=0; - extern float Height; +extern float Altitude; void Tag_App(void)//发送模式(TAG标签) { @@ -1291,6 +1298,7 @@ LED_LG_ON; Registor_Poll(); LED_LG_OFF; +// GetPressAndHeight(); break; case DISCPOLL: LED_LG_ON; @@ -1309,8 +1317,8 @@ break; case NEARPOLL: NearPoll(); - //GetPressAndHeight(); - //intheight = Height*100; + GetPressAndHeight(); + intheight =Altitude*100; break; case SINGLEPOLL: // Poll(); -- Gitblit v1.9.3