| | |
| | | u16 nearbaseid_list[MAX_NEARBASE_NUM],mainbase_id,true_nearbase_idlist[MAX_NEARBASE_NUM]; |
| | | int32_t mainbase_dist,nearbase_distlist[MAX_NEARBASE_NUM],true_nearbase_distlist[MAX_NEARBASE_NUM],true_exsistbase_list[MAX_NEARBASE_NUM]; |
| | | uint8_t trygetnearmsg_times; |
| | | u16 current_slotnum,total_slotnum,target_time; |
| | | u16 current_slotnum,total_slotnum,target_time,last_time; |
| | | u32 rec_tagpos_binary; |
| | | extern uint32_t tagpos_binary; |
| | | void SetNextPollTime(u16 time) |
| | | { |
| | | if(current_slotnum>=total_slotnum) |
| | | current_slotnum++; |
| | | if(current_slotnum==total_slotnum) |
| | | current_slotnum-=total_slotnum; |
| | | //time=5; |
| | | target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time); |
| | | if(target_time>=990&&target_time<1000) |
| | | |
| | | last_time=target_time; |
| | | if(target_time>=990&&target_time<992) |
| | | { |
| | | current_slotnum++; |
| | | target_time+=g_com_map[COM_INTERVAL]; |
| | | tagslotpos=GetRandomSlotPos(rec_tagpos_binary|tagpos_binary); |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | | } |
| | | if(target_time>=1000) |
| | | {target_time-=1000;} |
| | |
| | | u8 anclost_times=0; |
| | | u8 exsistbase_list[MAX_NEARBASE_NUM],report_num,get_newbase=0; |
| | | u16 temp_sync_timer1,temp_sync_timer2; |
| | | u32 rec_tagpos_binary; |
| | | extern uint32_t tagpos_binary; |
| | | |
| | | void NearPoll(void) |
| | | { |
| | | static u8 mainbase_lost_count=0,flag_finalsend,flag_rxon; |
| | |
| | | flag_rxon=1; |
| | | neartimout_timer=0; |
| | | get_newbase=0; |
| | | timeout=ceil((float)nearbase_num*0.4)+2; |
| | | timeout=ceil((float)nearbase_num*0.4)+3; |
| | | //timeout=5; |
| | | mainbase_dist=100000; |
| | | mainbase_lost_count++; |
| | |
| | | } |
| | | TIM3->CNT=tmp_time; |
| | | } |
| | | current_slotnum=temp_sync_timer1/g_com_map[COM_INTERVAL]; |
| | | // if(tagslotpos>max_slotpos) |
| | | // tagslotpos=tagslotpos%(max_slotpos+1); |
| | | // tyncpoll_time=(tagslotpos-1)*slottime; |
| | |
| | | // } |
| | | tagslotpos=GetRandomSlotPos(rec_tagpos_binary|tagpos_binary); |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | | tag_state=GETNEARMSG; |
| | | } |
| | | // tyncpoll_time=0; |
| | | next_nearbase_num=0; |
| | |
| | | { |
| | | nearbaseid_list[i]=true_nearbase_idlist[i]; |
| | | nearbase_distlist[i]=true_nearbase_distlist[i]; |
| | | if(nearbase_distlist[i]!=0x1ffff&&true_exsistbase_list[i]==0xa) |
| | | if(nearbase_distlist[i]!=0x1ffff&&true_exsistbase_list[i]==KEEP_TIMES) |
| | | { |
| | | memcpy(&usart_send[4+6*report_num],&nearbaseid_list[i],2); |
| | | memcpy(&usart_send[6+6*report_num],&nearbase_distlist[i],4); |
| | |
| | | } |
| | | |
| | | // printf("%d,%d",temp_sync_timer2,temp_sync_timer1); |
| | | // #ifdef USART_INTEGRATE_OUTPUT |
| | | // usart_send[2] = 4;//姝e父妯″紡 |
| | | // usart_send[3] = report_num*6+2;//姝e父妯″紡 |
| | | // checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | // memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | // UART_PushFrame(usart_send,6+report_num*6); |
| | | // #endif |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | usart_send[2] = 4;//姝e父妯″紡 |
| | | usart_send[3] = report_num*6+2;//姝e父妯″紡 |
| | | checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | UART_PushFrame(usart_send,6+report_num*6); |
| | | #endif |
| | | // if(mainbase_lost_count>5) |
| | | // { |
| | | // //tag_state=DISCPOLL; |
| | |
| | | //slottime=ceil((nearbase_num+2)*0.4)+2; |
| | | tyncpoll_time=tagslotpos*slottime; |
| | | tag_state=NEARPOLL; |
| | | }else{ |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | | } |
| | | }else{ |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | |
| | | NearPoll(); |
| | | break; |
| | | } |
| | | current_slotnum++; |
| | | |
| | | SetNextPollTime(tyncpoll_time); |
| | | g_start_send_flag = 0; |
| | | GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_RESET); |
| | | } |
| | | |