| | |
| | | void PushAnchorDataArray(uint16_t ancid,int16_t dist,uint8_t battary);//找到自己的id信息对应位置更新自己的交互信息 |
| | | static void resp_msg_set_ts(uint8_t *ts_field, int64_t ts);//用来对应位置放入时间戳 |
| | | static uint32_t tagid_list[TAG_NUM_IN_SYS]; |
| | | uint32_t fliter_tagid_list[TAG_NUM_IN_SYS]; |
| | | uint16_t CmpTagInList(uint16_t tagid); |
| | | uint8_t Anchor_RecNearPoll(uint8_t ancrec_nearbasepos); |
| | | static uint8_t send_buffer[100]; |
| | |
| | | taglist_num=j; |
| | | if(find_flag) |
| | | { |
| | | // if(tt5) |
| | | //if(tt5) |
| | | find_in_tag_id_authorization_list(tag_id_authorization_list_num); |
| | | find_flag=0; |
| | | } |
| | |
| | | resp_msg_set_ts(&send_buffer[RESP_MSG_POLL_RX_TS_IDX], poll_rx_ts_i64); |
| | | resp_msg_set_ts(&send_buffer[RESP_MSG_RESP_TX_TS_IDX], resp_tx_ts_i64);//此处时间戳int64直接转换为uint64不知道会不会有错误 |
| | | memcpy(&send_buffer[RESP_MSG_ANC_DISTOFFSET],&disoffset,2);//差个修正offset,修正有符号但是这个com表为无符号的,传过去直接赋给Int16_t相当于还原了 |
| | | send_buffer[RESP_MSG_TAG_FREQUENCY]=tag_near_frequency;//新加入改变标签测距hz |
| | | if(tagdist_list[ancrec_nearbasepos]<=change_by_frequency_distance) |
| | | { |
| | | send_buffer[RESP_MSG_TAG_FREQUENCY]=tag_near_frequency;//新加入改变标签测距hz |
| | | } |
| | | else{ |
| | | send_buffer[RESP_MSG_TAG_FREQUENCY]=1;//新加入改变标签测距hz |
| | | } |
| | | temp_resp_i64=resp_tx_ts_i64; |
| | | temp_count3= phy_timer_count_get(); |
| | | flag_temp2=uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小 |
| | |
| | | if (!swapped) break; |
| | | } |
| | | } |
| | | uint16_t tag_authorization_list_num_temp; |
| | | void fliter_tag_id_authorization_list(uint16_t*tag_authorization_list_real_num) |
| | | { |
| | | uint32_t filtered_count = 0; |
| | | |
| | | // 遍历所有标签,将距离小于阈值的ID存入结果数组 |
| | | for (uint32_t i = 0; i < taglist_num; i++) { |
| | | if (tagdist_list[i] < bind_distance&&tagid_list[i]!=0) { |
| | | fliter_tagid_list[filtered_count] = tagid_list[i]; |
| | | filtered_count++; |
| | | } |
| | | //fliter_tagid_list |
| | | } |
| | | *tag_authorization_list_real_num=filtered_count; |
| | | } |
| | | void copy_taglist_to_flash(void) |
| | | { |
| | | memcpy(&tag_id_authorization_list,&tagid_list,taglist_num*4); |
| | | //进行排序后存入,为二分法做基础 |
| | | bubble_sort(&tag_id_authorization_list,taglist_num); |
| | | save_taglist_map_to_flash(); |
| | | fliter_tag_id_authorization_list(&tag_authorization_list_num_temp);//过滤调id为0的标签和不满足绑定距离的标签 |
| | | memset(tag_id_authorization_list,0,sizeof(tag_id_authorization_list));//清空上一次数组防止重叠 |
| | | memcpy(&tag_id_authorization_list,&fliter_tagid_list,tag_authorization_list_num_temp*4);//复制满足条件数组 |
| | | bubble_sort(&tag_id_authorization_list,tag_authorization_list_num_temp);//进行排序后存入,为二分法做基础 |
| | | save_taglist_map_to_flash();//存入flash |
| | | } |
| | | |
| | | void find_in_tag_id_authorization_list(uint32_t authorization_list_num) |
| | |
| | | Anchor_RecNearPoll(i); |
| | | tagdist_list[taglist_pos]=rec_ancdistlist[i]; |
| | | anchordata_bat[taglist_pos] = battary;//保存该基站电量 |
| | | if(tag_authorized_List[taglist_pos]==1) |
| | | if(tag_authorized_List[taglist_pos]==1) |
| | | { |
| | | if(tagdist_list[taglist_pos]<button_determinate_distance) |
| | | { |
| | | if(tagdist_list[taglist_pos]<bind_distance) |
| | | { |
| | | gpio_pin_set(BUTTON_PIN); |
| | | }else{ |
| | | }else{ |
| | | gpio_pin_clr(BUTTON_PIN); |
| | | } |
| | | } |
| | | } |
| | | if(taglist_pos==taglist_num)// taglist_pos==taglist_num 说明这个基站不在当前列表中 |
| | | { //tempid==dev_id 说明基站下发测距报文有这个标签的信息 |
| | | taglist_num++; //满足上述两种情况才会添加基站ID进入列表中,否则会出现标签不在基站列表中,标签也不响应的情况 |