| | |
| | | uint32_t range_timeout_us = 2000000;//yuan5000 |
| | | uint8_t flag_temp2,flag_temp1; |
| | | uint16_t uwb_losttimer; |
| | | uint8_t mac_error; |
| | | //uint8_t mac_error; |
| | | uint8_t allow_flag; |
| | | uint8_t resp_tx_flag,poll_rx_error_num; |
| | | uint8_t tag_rssi[TAG_NUM_IN_SYS]; |
| | |
| | | //} |
| | | } |
| | | float temp1,temp2; |
| | | uint8_t aoa_fom[TAG_NUM_IN_SYS]; |
| | | static void angle_result_filter(uint8_t *mac_addr, int16_t *angle, uint8_t type) |
| | | { |
| | | if (angle == NULL) |
| | |
| | | angle_result_filter(&mac_addr,&elevation, KF_DATA_TYPE_ELEVATION); |
| | | angle_azimuth[taglist_pos]=(uint16_t)mk_q7_to_s16(azimuth); |
| | | angle_elevation[taglist_pos]=(uint16_t)mk_q7_to_s16(elevation); |
| | | aoa_fom[taglist_pos]=fom; |
| | | //buffer_message_send(); |
| | | //int16_t azimth=mk_q7_to_s16(azimuth),elevate=mk_q7_to_s16(elevation); |
| | | |
| | | // // filter process |
| | | |
| | | LOG_INFO(TRACE_MODULE_APP, "PDoA 0x%04x Azimuth %d Elevation %d FoM %u\r\n",tag_id_recv, mk_q7_to_s16(azimuth), |
| | | LOG_INFO(TRACE_MODULE_APP, "PDoA 0x%04x Azimuth %d Elevation %d FoM %u \r\n",tag_id_recv, mk_q7_to_s16(azimuth), |
| | | mk_q7_to_s16(elevation), fom); |
| | | allow_flag=0; |
| | | } |
| | |
| | | OpenUWB();//再次开启UWB接收 |
| | | //LOG_INFO(TRACE_MODULE_APP, "poll_rx_num is %d,resp_tx_num is %d\r\n",poll_rx_num,resp_tx_num); |
| | | }else{ |
| | | mac_error=1; |
| | | //mac_error=1; |
| | | } |
| | | } |
| | | uint32_t start_receive_count,end_receive_count,poll_timeout,current_count,temp_resp; |
| | |
| | | extern uint32_t tag_id_authorization_list[1024]; |
| | | static uint8_t anchordata_bat[TAG_NUM_IN_SYS]; |
| | | uint8_t anchordata_num = 0; |
| | | static int32_t tagdist_list[TAG_NUM_IN_SYS]; |
| | | uint8_t rssi_quality[TAG_NUM_IN_SYS]; |
| | | static int16_t tagdist_list[TAG_NUM_IN_SYS]; |
| | | |
| | | uint16_t state_button[TAG_NUM_IN_SYS]; |
| | | uint16_t pressure[TAG_NUM_IN_SYS]; |
| | | uint16_t random_time; |
| | |
| | | tagid_list[j] = tagid_list[j + 1]; |
| | | tagid_list[j + 1] = temp_id; |
| | | |
| | | //同步交换电量是否授权表和在线时间 |
| | | //同步交换电量 |
| | | uint32_t temp_bat = anchordata_bat[j]; |
| | | anchordata_bat[j]=anchordata_bat[j+1];//电量随之更新 |
| | | anchordata_bat[j+1]=temp_bat; |
| | |
| | | tagofflinetime[j]=tagofflinetime[j+1];//电量随之更新 |
| | | tagofflinetime[j+1]=temp_tag_offlinetime; |
| | | |
| | | //水平角度交换 |
| | | uint16_t temp_tag_azimuth=angle_azimuth[j]; |
| | | angle_azimuth[j]=angle_azimuth[j+1]; |
| | | angle_azimuth[j+1]=temp_tag_azimuth; |
| | | //垂直角度交换 |
| | | uint16_t temp_tag_elevation=angle_elevation[j]; |
| | | angle_elevation[j]=angle_elevation[j+1]; |
| | | angle_elevation[j+1]=temp_tag_elevation; |
| | | //信号强度交换 |
| | | uint8_t rssi_temp=tag_rssi[j]; |
| | | tag_rssi[j]=tag_rssi[j+1]; |
| | | tag_rssi[j+1]=rssi_temp; |
| | | //角度置信度交换 |
| | | uint8_t temp_fom=aoa_fom[j]; |
| | | aoa_fom[j]=aoa_fom[j+1]; |
| | | aoa_fom[j+1]=temp_fom; |
| | | //设备状态交换 |
| | | uint16_t temp_state=state_button[j]; |
| | | state_button[j]=state_button[j+1]; |
| | | state_button[j+1]=temp_state; |
| | | //气压交换 |
| | | uint16_t temp_pressure=pressure[j]; |
| | | pressure[j]=pressure[j+1]; |
| | | pressure[j+1]=temp_pressure; |
| | | //包序交换 |
| | | uint8_t seq_temp=tag_seq[j]; |
| | | tag_seq[j]=tag_seq[j+1]; |
| | | tag_seq[j+1]=seq_temp; |
| | | //showbuffer交换 |
| | | uint8_t show_location_temp=show_location[j]; |
| | | show_location[j]=show_location[j+1]; |
| | | show_location[j+1]=show_location_temp; |
| | | // //同步交换授权表 |
| | | // uint8_t temp_tag_authorized = tag_authorized_List[j]; |
| | | // tag_authorized_List[j]=tag_authorized_List[j+1];//电量随之更新 |
| | |
| | | } |
| | | taglist_num=j; |
| | | sort_tag_lists();//增加距离小的排到前面逻辑 |
| | | buffer_message_send();//发送测距报文信息 |
| | | update_show_buffer();//根据角度和距离判断区域位置 |
| | | //delay_ms(10); |
| | | buffer_485_send(show_location);//发送显示信息 |
| | | //update_show_buffer();//根据角度和距离判断区域位置 |
| | | // gpio_pin_set(CHANGE_UART_PIN);//;拉高打印输出 |
| | | //buffer_message_send();//发送测距报文信息 |
| | | //buffer_485_send(show_location);//发送显示信息 |
| | | // while(uart_tx_in_progress(UART_ID0)); |
| | | // gpio_pin_clr(CHANGE_UART_PIN);//;拉低变接收 |
| | | } |
| | | |
| | | uint8_t position; |
| | |
| | | uwb_rx_flag=1; |
| | | //LOG_INFO(TRACE_MODULE_APP,"打开uwb_rx\r\n"); |
| | | } |
| | | //uint8_t temp_tag_num; |
| | | void UWBOneSecondTask(void) |
| | | { |
| | | TagListUpdate();//更新标签数 |
| | |
| | | #define AREA_8 0xa8 |
| | | uint8_t change_by_distance(uint8_t position,uint16_t distance) |
| | | { |
| | | if(distance<1000){ |
| | | if(distance<g_com_map[ALARM_DISTANCE1]){ |
| | | position=position; |
| | | }else if (distance>1000&&distance<2000){ |
| | | }else if (distance>g_com_map[ALARM_DISTANCE1]&&distance<g_com_map[ALARM_DISTANCE2]){ |
| | | position=position+16; |
| | | }else if (distance>2000&&distance<3000){ |
| | | }else if (distance>g_com_map[ALARM_DISTANCE2]&&distance<g_com_map[ALARM_DISTANCE3]){ |
| | | position=position+16; |
| | | } |
| | | return position; |
| | |
| | | memcpy(&usart0_send[4],&dev_id,2); //anchor_id |
| | | for(uint8_t i=0;i<taglist_num;i++) |
| | | { |
| | | memcpy(&usart0_send[6+i*16],tagid_list[i],2); |
| | | usart0_send[8+i*20] = tag_seq[i];//包序 |
| | | memcpy(&usart0_send[6+i*16],&tagid_list[i],2); |
| | | usart0_send[8+i*16] = tag_seq[i];//包序 |
| | | memcpy(&usart0_send[9+i*16],&tagdist_list[i],2); //distance |
| | | memcpy(&usart0_send[11+i*16],&angle_azimuth[i],2);//angle_azithum |
| | | memcpy(&usart0_send[13+i*16],&angle_elevation[i],2);//angle_elevation |
| | | memcpy(&usart0_send[15+i*16],&tag_rssi[i],1); //信号强度 |
| | | memcpy(&usart0_send[16+i*16],&rssi_quality[i],1); //信号质量预留 |
| | | usart0_send[17+i*20]=anchordata_bat[i];//标签电量 |
| | | memcpy(&usart0_send[16+i*16],&aoa_fom[i],1); //信号质量预留 |
| | | usart0_send[17+i*16]=anchordata_bat[i];//标签电量 |
| | | memcpy(&usart0_send[18+i*16],&state_button[i],2); //设备状态 |
| | | memcpy(&usart0_send[20+i*16],&pressure[i],2); //气压 |
| | | } |
| | | memcpy(&usart0_send[6+taglist_num*16],&yuliu,4); //预留位4位 |
| | | checksum = Checksum_u16(&usart0_send[2],8+16*taglist_num); |
| | | memcpy(&usart0_send[10+16*taglist_num], &checksum, 2); |
| | | gpio_pin_set(CHANGE_UART_PIN);//;拉高打印输出 |
| | | uart_send(UART_ID0, usart0_send,12+16*taglist_num, NULL); |
| | | while(uart_tx_in_progress(UART_ID0)); |
| | | gpio_pin_clr(CHANGE_UART_PIN);//;拉低变接收 |
| | | } |
| | | int Anchor_App(void) |
| | | { |
| | |
| | | static struct KF_MAT_VALUE_CACHE_T kf_mat_value_cache[KF_SUPPORT_NUM]; |
| | | void Anchor_uwb_aoa_square_init(void) |
| | | { |
| | | uwb_open(); |
| | | |
| | | // Set calibration parameters |
| | | uwb_calibration_params_set(config.phy_cfg.ch_num); |
| | | |