From a012ce64e17eda877927b1a0ffca79159ee0e57d Mon Sep 17 00:00:00 2001 From: zhangbo <zhangbo@qq.com> Date: 星期五, 28 三月 2025 17:59:21 +0800 Subject: [PATCH] 功耗室外45ma室内20ma,现在5s上传1次GNGGA,55AAuwb测距,室内上传1分钟一次带室内外标志位的心跳包 --- keil/uwb_app.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 92 insertions(+), 8 deletions(-) diff --git a/keil/uwb_app.c b/keil/uwb_app.c index ba131ee..90ab06d 100644 --- a/keil/uwb_app.c +++ b/keil/uwb_app.c @@ -11,6 +11,8 @@ #include "board.h" #include "lib_aoa.h" #include "WS2812.h" +#include "PCA9555.h" +#include "GPS.h" extern int simple_main(void); extern int temp_main(void); void Calibration_Time(void); @@ -343,7 +345,7 @@ memcpy(&rx_rpt, rx_report, sizeof(struct MAC_HW_REPORT_T)); rx_length = 0; receive_error_flag=1; - OpenUWB();//再次开启UWB接收 + OpenUWB();//再次开启UWB接收 } // CloseUWB(); // OpenUWB();//再次开启UWB接收 @@ -479,6 +481,9 @@ // } // anchordata_num=j; //} +extern uint8_t in_the_room_flag; +extern uint8_t lounei_flag; +uint8_t ceju_onlinetime; void TagListUpdate(void) { uint16_t i,j=0,k=0; @@ -491,7 +496,15 @@ anchordata_bat[j]=anchordata_bat[i];//电量随之更新 anchor_rssi[j]=anchor_rssi[i]; tagofflinetime[j++]=tagofflinetime[i]; + in_the_room_flag=0; + ceju_onlinetime++; } + + } + if(ceju_onlinetime>0||taglist_num==0) + { + ceju_onlinetime=0; + in_the_room_flag=1; } taglist_num=j; } @@ -602,11 +615,11 @@ } void OpenUWB(void) { -// while(!mac_is_busy()) -// { +// while(!mac_is_busy()) +// { flag_temp1=uwb_rx(0, 0,range_timeout_us);//提交接收请求 uwb_rx_flag=1; -// } +// } //LOG_INFO(TRACE_MODULE_APP,"打开uwb_rx\r\n"); } void UWBOneSecondTask(void) @@ -616,6 +629,8 @@ if(uwb_losttimer>g_com_map[UWB_RNAGE_TIME]) uwb_losttimer=g_com_map[UWB_RNAGE_TIME]+1;//防止溢出 } +extern uint8_t heart_upload_time; +uint16_t count_hexupload; void UWBSendUDPTask(void) { uint16_t checksum,tempdistarray[20]; @@ -680,7 +695,11 @@ memcpy(&usart_send[17+taglist_num*4],&anchordata_bat,taglist_num); checksum = Checksum_u16(&usart_send[2],15+5*taglist_num); memcpy(&usart_send[17+5*taglist_num],&checksum,2); - HexToAsciiSendUDP(usart_send,19+5*taglist_num); + if(lounei_flag==0&&heart_upload_time%UPLOAD_4G_TIME==0) + { + HexToAsciiSendUDP(usart_send,19+5*taglist_num); + count_hexupload++; + } taglist_num = 0; // rxnum=0; } @@ -704,10 +723,63 @@ UWBSendUDPTask(); } } +//int uwb_app_poll(void) +//{ +// +// UWBIdleTask(); +//} +//enumwltagstate wltag_state=RANGE; +uint32_t wltag_statetimer,wltag_uwbtimer; int uwb_app_poll(void) { + switch(wltag_state) + { + + case RANGE: +// time_flag=HIDO_TimerGetTick()-wltag_uwbtimer; + if(HIDO_TimerGetTick()-wltag_uwbtimer>4&&uwb_rx_flag==0) + { + wltag_uwbtimer = HIDO_TimerGetTick(); + OpenUWB(); + + } + else if(HIDO_TimerGetTick()-wltag_uwbtimer>1&&uwb_rx_flag==1) + { +// time_flag=HIDO_TimerGetTick()-wltag_uwbtimer; + wltag_uwbtimer = HIDO_TimerGetTick(); + CloseUWB(); + } + if(uwb_losttimer>g_com_map[UWB_RNAGE_TIME]) + { + wltag_statetimer = HIDO_TimerGetTick(); + if(uwb_rx_flag==0)//若要切换到搜索模式时没有开启则开启UWB + { + OpenUWB(); + } + wltag_state = SEARCH; + } + break; + case SEARCH: + if(HIDO_TimerGetTick()-wltag_statetimer>1) + { + wltag_statetimer = HIDO_TimerGetTick(); + wltag_state = CLOSE; + CloseUWB(); + + } + break; + case CLOSE: + if(HIDO_TimerGetTick()-wltag_statetimer>g_com_map[UWB_WAIT_TIME]) + { + wltag_statetimer = HIDO_TimerGetTick(); + wltag_state = SEARCH; + OpenUWB(); + } + break; + } UWBIdleTask(); } +uint8_t in_the_room_flag=0; int Anchor_App(void) { uint8_t i; @@ -761,12 +833,24 @@ Anchor_RecNearPoll(i); tagdist_list[taglist_pos]=rec_ancdistlist[i]; anchordata_bat[taglist_pos] = battary;//保存该基站电量 - anchor_rssi[taglist_pos]=rssi; + anchor_rssi[taglist_pos]=rssi; +// in_the_room_flag=1; +// if(dev_id==g_com_map[DOOR_UWB_1]) +// { +// +// } +// if(dev_id==g_com_map[DOOR_UWB_2]) +// { +// +// } +// if(dev_id==g_com_map[DOOR_UWB_3]) +// { +// IN_THE_ROOM_FLAG=1; +// } if(taglist_pos==taglist_num)// taglist_pos==taglist_num 说明这个基站不在当前列表中 { //tempid==dev_id 说明基站下发测距报文有这个标签的信息 taglist_num++; //满足上述两种情况才会添加基站ID进入列表中,否则会出现标签不在基站列表中,标签也不响应的情况 - tagid_list[taglist_pos] = tag_id_recv; - + tagid_list[taglist_pos] = tag_id_recv; } break; } -- Gitblit v1.9.3