| | |
| | | uint32_t temp_key; |
| | | uint8_t required_size_temp; |
| | | uint8_t delete_count_temp; |
| | | int low_temp,high_temp,mid_temp; |
| | | int low_temp,high_temp,mid_temp,elements_to_move_temp,temp_index; |
| | | void delete_authorization_list(uint8_t* delete_list,uint32_t*tag_authorization_idlist,uint32_t*authorization_list_num) |
| | | { |
| | | if (*authorization_list_num == 0) { |
| | |
| | | temp_key=key; |
| | | while (low <= high) { |
| | | int mid = low + (high - low) / 2; // 防止整数溢出 |
| | | |
| | | LOG_INFO(TRACE_MODULE_APP,"high%d,low%d,mid%d,key%#x\r\n",high,low,mid,key); |
| | | if (tag_id_authorization_list[mid] == key) { |
| | | found = 1; // 找到匹配项 |
| | | index=mid; |
| | | temp_index=index; |
| | | break; |
| | | } else if (tag_id_authorization_list[mid] < key) { |
| | | low = mid + 1; // 在右半部分继续查找 |
| | | } else { |
| | | high = mid - 1; // 在左半部分继续查找 |
| | | } |
| | | mid_temp=mid;//测试 |
| | | |
| | | } |
| | | |
| | | if(found) |
| | | { |
| | | LOG_INFO(TRACE_MODULE_APP,"进入删除index%d,key%#x\r\n",index,key); |
| | | int elements_to_move = *authorization_list_num - index - 1; |
| | | elements_to_move_temp=elements_to_move; |
| | | if (elements_to_move > 0) { |
| | | // 计算源地址和目标地址 |
| | | void *src = (uint32_t *)tag_authorization_idlist + (index + 1); |
| | |
| | | // 使用memmove进行内存块移动(处理重叠内存区域) |
| | | memmove(dest, src, elements_to_move * 4); |
| | | *authorization_list_num=*authorization_list_num-1;//成功删除一个更新数量 |
| | | tag_authorization_idlist[*authorization_list_num]=0xffffffff;//将多余重叠部分重置 |
| | | }else if (elements_to_move==0&&index==0){ |
| | | *authorization_list_num=*authorization_list_num-1;//成功删除一个更新数量 |
| | | tag_authorization_idlist[index]=0xffffffff; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | extern uint8_t bind_flag; |
| | | void Usart0ParseDataHandler(uint8_t data) |
| | | { |
| | | // 全局变量 |
| | |
| | | case BIND_DISTANCE_FOR_TAG: |
| | | memcpy(&bind_distance,&mUsart2ReceivePack[0],2); |
| | | memcpy(&g_com_map[BIND_DISTANCE],&bind_distance,2); |
| | | bind_flag=1; |
| | | save_com_map_to_flash(); |
| | | break; |
| | | case DELETE_ALL: |
| | | memset(tag_id_authorization_list,0,sizeof(tag_id_authorization_list)); |
| | | save_taglist_map_to_flash(); |
| | | break; |
| | | case DELETE_PART: |
| | | delete_authorization_list(&mUsart2ReceivePack,&tag_id_authorization_list,&tag_id_authorization_list_num);//删表中元素操作 |
| | | break; |
| | | save_taglist_map_to_flash(); |
| | | break; |
| | | case SET_DISTANCE_DETERMINATION: |
| | | memcpy(&button_determinate_distance,&mUsart2ReceivePack[0],2);//设定开关判断距离 |
| | | memcpy(&g_com_map[DETERMINATION_DISTANCE],&button_determinate_distance,2); |