| | |
| | | #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); |
| | |
| | | extern uint8_t group_id; |
| | | static uint16_t anc_id_recv,tag_id_recv; |
| | | static int16_t rec_antdelay; |
| | | extern uint32_t dev_id; |
| | | extern uint16_t dev_id; |
| | | static uint16_t taglist_pos,tmp_time; |
| | | extern uint16_t tag_frequency; |
| | | extern uint16_t disoffset; |
| | |
| | | uint8_t receive_error_flag; |
| | | uint8_t rxnumoknum,rxnumerrornum; |
| | | uint8_t resp_tx_flag; |
| | | extern uint8_t ceju_onlinetime; |
| | | extern uint8_t in_the_room_flag; |
| | | static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report) |
| | | { uint8_t valid_sts=0; |
| | | // Power off radio |
| | |
| | | temp_count= phy_timer_count_get(); |
| | | memcpy(&rx_rpt, rx_report, sizeof(struct MAC_HW_REPORT_T)); |
| | | rx_length = 0; |
| | | // ceju_onlinetime==0; |
| | | // in_the_room_flag++; |
| | | receive_error_flag=1; |
| | | OpenUWB();//再次开启UWB接收 |
| | | OpenUWB();//再次开启UWB接收 |
| | | } |
| | | // CloseUWB(); |
| | | // OpenUWB();//再次开启UWB接收 |
| | |
| | | uint32_t start_receive_count,end_receive_count,poll_timeout,current_count,temp_resp; |
| | | uint16_t anchordata_id[TAG_NUM_IN_SYS],anchordata_dist[TAG_NUM_IN_SYS]; |
| | | static uint8_t anchordata_bat[TAG_NUM_IN_SYS]; |
| | | static int8_t anchor_rssi[TAG_NUM_IN_SYS]; |
| | | uint8_t anchordata_num = 0; |
| | | static int16_t tagdist_list[TAG_NUM_IN_SYS]; |
| | | uint16_t random_time; |
| | |
| | | // } |
| | | // anchordata_num=j; |
| | | //} |
| | | extern uint8_t in_the_room_flag; |
| | | extern uint8_t lounei_flag; |
| | | uint8_t ceju_onlinetime; |
| | | uint16_t last_id=0; |
| | | uint8_t ceju_leave_flag=0; |
| | | void TagListUpdate(void) |
| | | { |
| | | uint16_t i,j=0,k=0; |
| | |
| | | tagid_list[j]=tagid_list[i]; |
| | | tagdist_list[j] = tagdist_list[i]; |
| | | anchordata_bat[j]=anchordata_bat[i];//电量随之更新 |
| | | anchor_rssi[j]=anchor_rssi[i]; |
| | | tagofflinetime[j++]=tagofflinetime[i]; |
| | | // in_the_room_flag=0; |
| | | last_id=tagid_list[i]; |
| | | if(last_id=tagid_list[i]) |
| | | { |
| | | ceju_onlinetime++; |
| | | } |
| | | |
| | | } |
| | | } |
| | | // if(ceju_onlinetime==0&&taglist_num==0) |
| | | // { |
| | | // in_the_room_flag=0; |
| | | // } |
| | | // if(ceju_onlinetime>1&&taglist_num==0) |
| | | // { |
| | | // in_the_room_flag=1; |
| | | // } |
| | | if(ceju_onlinetime>0&&taglist_num==0) |
| | | { |
| | | ceju_onlinetime=0; |
| | | ceju_leave_flag=1; |
| | | } |
| | | taglist_num=j; |
| | | } |
| | |
| | | } |
| | | 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) |
| | |
| | | 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; |
| | | extern uint8_t open_gps_time; |
| | | void UWBSendUDPTask(void) |
| | | { |
| | | uint16_t checksum,tempdistarray[20]; |
| | |
| | | { |
| | | uint16_t id,dist; |
| | | uint8_t bat; |
| | | int8_t rssi1; |
| | | id = tagid_list[j]; |
| | | dist = tagdist_list[j]; |
| | | bat = anchordata_bat[j]; |
| | | rssi1=anchor_rssi[j]; |
| | | tagid_list[j] = tagid_list[j+1]; |
| | | tagdist_list[j] = tagdist_list[j+1]; |
| | | anchordata_bat[j] = anchordata_bat[j+1]; |
| | | anchor_rssi[j] = anchor_rssi[j+1]; |
| | | tagid_list[j+1] = id; |
| | | tagdist_list[j+1] = dist; |
| | | anchordata_bat[j+1] = bat; |
| | | anchor_rssi[j+1] = rssi1; |
| | | } |
| | | } |
| | | |
| | |
| | | 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((heart_upload_time%UPLOAD_4G_TIME==0&&lounei_flag==0&&open_gps_time>120)||(open_gps_time%UPLOAD_4G_TIME==0&&lounei_flag==0&&open_gps_time<120)) |
| | | { |
| | | HexToAsciiSendUDP(usart_send,19+5*taglist_num); |
| | | count_hexupload++; |
| | | } |
| | | taglist_num = 0; |
| | | // rxnum=0; |
| | | } |
| | |
| | | UWBSendUDPTask(); |
| | | } |
| | | } |
| | | //int uwb_app_poll(void) |
| | | //{ |
| | | // |
| | | // UWBIdleTask(); |
| | | //} |
| | | //enumwltagstate wltag_state=RANGE; |
| | | uint32_t wltag_statetimer,wltag_uwbtimer; |
| | | extern uint16_t uwb_time_count; |
| | | int uwb_app_poll(void) |
| | | { |
| | | switch(uwb_time_count) |
| | | { |
| | | case 1: |
| | | CloseUWB(); |
| | | break; |
| | | case 5: |
| | | OpenUWB(); |
| | | uwb_time_count=0; |
| | | 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; |
| | | PCA9555_Set_One_Value_Output(GPS_POWER,1); |
| | | if(taglist_pos==taglist_num)// taglist_pos==taglist_num 说明这个基站不在当前列表中 |
| | | { //tempid==dev_id 说明基站下发测距报文有这个标签的信息 |
| | | taglist_num++; //满足上述两种情况才会添加基站ID进入列表中,否则会出现标签不在基站列表中,标签也不响应的情况 |
| | | tagid_list[taglist_pos] = tag_id_recv; |
| | | |
| | | PCA9555_Set_One_Value_Output(GPS_POWER,1); |
| | | } |
| | | break; |
| | | } |