| | |
| | | uint32_t temp_count2=0; |
| | | uint32_t temp_count3=0; |
| | | uint32_t temp_internal=0; |
| | | int temp_flag,distance; |
| | | int32_t distance; |
| | | uint8_t taglist_num; |
| | | extern uint8_t recev_error_num; |
| | | |
| | |
| | | #define FINAL_MSG_RESP_RX_TS_IDX 14 |
| | | #define FINAL_MSG_FINAL_TX_TS_IDX 18 |
| | | #define DELAY_DEFAULT 1000 |
| | | #define HALF_SECOND_TIME 62400000 |
| | | #define HALF_SECOND_TIME 624000000 |
| | | /* Length of the common part of the message */ |
| | | #define MSG_COMMON_LEN 10 |
| | | |
| | |
| | | } |
| | | |
| | | /* RX done process handler. */ |
| | | int8_t rssi; |
| | | static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report) |
| | | { |
| | | // Power off radio |
| | |
| | | poll_rx_en_start_u32 = rx_rpt.timestamp - phy_shr_duration(); |
| | | poll_rx_ts_i64 = ranging_rx_time_correct(&rx_rpt); |
| | | poll_rx_num++; |
| | | rssi = rx_report->rssi; |
| | | receive_flag=1; |
| | | recev_error_num=0; |
| | | } |
| | |
| | | anchordata_dist[i] = dist; |
| | | anchordata_bat[i] = battary; |
| | | tagofflinetime[i]=0;//不断更新当前TAG对应离线时间 |
| | | //if(dist>0) |
| | | distance=dist; |
| | | } |
| | | uint16_t CmpTagInList(uint16_t tagid) |
| | |
| | | memcpy(&send_buffer[RESP_MSG_ANC_DISTOFFSET],&disoffset,2);//差个修正offset,修正有符号但是这个com表为无符号的,传过去直接赋给Int16_t相当于还原了 |
| | | temp_resp_i64=resp_tx_ts_i64; |
| | | temp_count3= phy_timer_count_get(); |
| | | temp_flag=uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小 |
| | | uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小 |
| | | temp_count1=phy_timer_count_get(); |
| | | while(mac_is_busy()); |
| | | gpio_pin_clr(SCL_PIN); |
| | | } |
| | | uint16_t uwb_searchcount; |
| | | extern uint8_t g_start_send_flag,search_open_flag = 1,link_success_flag; |
| | | int UwbRange(void) |
| | | { |
| | | uint8_t i; |
| | |
| | | { |
| | | if(rec_ancidlist[i] == dev_id) |
| | | { |
| | | rec_ancdistlist[i]+=(int16_t)g_com_map[DIST_OFFSET]; |
| | | PushAnchorDataArray(tag_id_recv,rec_ancdistlist[i],battary); |
| | | } |
| | | } |
| | |
| | | Anchor_RecNearPoll(i); |
| | | |
| | | } |
| | | |
| | | LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度:%d.\r\n",g_com_map[BIND_DEV_ID],distance,rssi); |
| | | } |
| | | }else{ |
| | | |
| | | if(recev_error_num++>20) |
| | | LOG_INFO(TRACE_MODULE_APP,"测距失败\r\n"); |
| | | if(recev_error_num++>5) |
| | | { |
| | | recev_error_num=0; |
| | | UWB_work_state=SEARCH_DEV; |
| | | uwb_searchcount = 0; |
| | | search_open_flag = 1; |
| | | } |
| | | } |
| | | sleep_timer_start(__MS_TO_32K_CNT(UWB_DELAY_TIME_US));//测试 |
| | |
| | | current_count=phy_timer_count_get(); |
| | | if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) |
| | | { |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | |
| | | //} |
| | | |
| | | #define SEARCH_TIMESTEMP 120 |
| | | uint16_t uwb_searchcount; |
| | | extern uint8_t g_start_send_flag,search_open_flag = 1,link_success_flag; |
| | | void UWBPoll(void) |
| | | { |
| | | LOG_INFO(TRACE_MODULE_APP,"UWB状态:%d\r\n",UWB_work_state); |
| | | switch(UWB_work_state) |
| | | { |
| | | case LINK_SUCCESS: |
| | |
| | | { //接包不成功或者通讯失败进入搜索模式 |
| | | if(search_open_flag) |
| | | { |
| | | first_search_flag=0; |
| | | LOG_INFO(TRACE_MODULE_APP,"开启搜索\r\n"); |
| | | search_open_flag=0; |
| | | uwb_led_on(); |
| | | link_success_flag=UwbSearch();//第一次开启接收2s绑定失败后则进行下面1分钟后重新开启2s绑定流程 |
| | | uwb_led_off(); |