| | |
| | | #include "board.h" |
| | | #include "lib_aoa.h" |
| | | #include "WS2812.h" |
| | | #include "PCA9555.h" |
| | | extern int simple_main(void); |
| | | extern int temp_main(void); |
| | | void Calibration_Time(void); |
| | |
| | | #ifdef DW1000 |
| | | static struct mk_uwb_configure config = { |
| | | .phy_work_mode = (uint8_t)(PHY_TX | PHY_RX), |
| | | .phy_cfg.ch_num = 9, /* Channel number. */ |
| | | .phy_cfg.ch_num = 5, /* Channel number. */ |
| | | .phy_cfg.code_index = 9, /* TRX preamble code */ |
| | | .phy_cfg.mean_prf = MEAN_PRF_64M, /* Mean prf 64/128/256M */ |
| | | .phy_cfg.data_bit_rate = DATA_BR_6M8, /* Data rate 6.8M */ |
| | |
| | | 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接收 |
| | |
| | | // } |
| | | // 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | 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>2&&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; |
| | |
| | | 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; |
| | | } |