From 8aa343c68337975234072baae5eda592487c4271 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期六, 16 八月 2025 18:29:41 +0800 Subject: [PATCH] 防丢手环V1.0demo版本实现一对多测距和发送震动信息 --- keil/uwb_app.c | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/keil/uwb_app.c b/keil/uwb_app.c index a27f5d6..d04574d 100644 --- a/keil/uwb_app.c +++ b/keil/uwb_app.c @@ -486,6 +486,9 @@ } return false; } +uint8_t num1; +uint8_t pos_temp; +uint8_t motor_send_flag; uint8_t Anchor_RecNearPoll(uint8_t ancrec_nearbasepos)//根据自己是否为新基站定制消息去发送,根据是否抢占判断 { temp_count2=poll_rx_en_start_u32; @@ -494,11 +497,14 @@ memcpy(&send_buffer[ANCHOR_ID_IDX],&dev_id,2);//自身id memcpy(&send_buffer[TAG_ID_IDX],&tag_id_recv,2);//接受者id send_buffer[MESSAGE_TYPE_IDX]=MBX_RESPONSE; - if(tagdist_list[ancrec_nearbasepos]<=g_com_map[ALARM_DISTANCE1]) - send_buffer[RESP_MSG_TAG_MOTOR]=5;//下发标签5s震动 - else +if(tagdist_list[taglist_pos]<=g_com_map[ALARM_DISTANCE1]&&tagdist_list[taglist_pos]!=0) + {send_buffer[RESP_MSG_TAG_MOTOR]=5;//下发标签5s震动 + num1++; + }else{ send_buffer[RESP_MSG_TAG_MOTOR]=0;//不震动 - + num1=0; + } + pos_temp=taglist_pos; // if(rec_nearbase_num == ancrec_nearbasepos)//抢占模式自己为新基站 // { // random_time = (phy_timer_count_get()%100);//多基站抢占一个位置时避免一个也收不到的情况就每一个随机错开几十uS @@ -522,6 +528,7 @@ temp_count3= phy_timer_count_get(); flag_temp2=uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小 tagofflinetime[taglist_pos] = 0;//更新标签通信 +// motor_send_flag=0; // temp_count1=phy_timer_count_get(); //while(mac_is_busy()); //gpio_pin_clr(SCL_PIN); @@ -705,7 +712,13 @@ { memcpy(&tempid,&rx_buf[FZ_NEARBASEID_INDEX+i*2],2); if(tempid==dev_id) - { + { +// if(tagdist_list[taglist_pos]<=g_com_map[ALARM_DISTANCE1]&&tagdist_list[taglist_pos]!=0) +// { +// motor_send_flag=1; +// }else{ +// motor_send_flag=0; +// } Anchor_RecNearPoll(i); tagdist_list[taglist_pos]=rec_ancdistlist[i]; anchordata_bat[taglist_pos] = battary;//保存该基站电量 -- Gitblit v1.9.3