| | |
| | | uint16_t current_slotpos = 0; |
| | | |
| | | uint8_t rec_anc_sync_sec,tagpoll_sync_sec,current_sync_sec,flag_tagnewpos; |
| | | |
| | | void GetNearMsg(void); |
| | | static uint64_t get_tx_timestamp_u64(void) |
| | | { |
| | | uint8_t ts_tab[5]; |
| | |
| | | trygetnearmsg_times = 0; |
| | | tag_state = GETNEARMSG; |
| | | mainbase_id = mindist_ancid; |
| | | GetNearMsg(); |
| | | } |
| | | |
| | | if(getsync_flag==0) |
| | |
| | | last_lpcount = lpcount; |
| | | } |
| | | uint16_t rec_tagperiod; |
| | | u8 nearmsg_mainbase=0,rec_tagpos_emptylist[32],mainbase_type;; |
| | | u8 nearmsg_mainbase=0,rec_tagpos_emptylist[32],mainbase_type; |
| | | int8_t notenoughdist_count=0; |
| | | void GetNearMsg(void) |
| | | { |
| | | u32 start_poll,frame_len; |
| | |
| | | nearbase_distlist[nearmsg_i] = 0x1ffff; |
| | | } |
| | | //mainbase_id = 0x9818; |
| | | notenoughdist_count = -2; |
| | | memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2); |
| | | memcpy(&tx_near_msg[TAG_ID_IDX],&dev_id,2); |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = POS_MSG; |
| | |
| | | uint8_t pack_length = 0,pack_index = 0,pack_msgtype = 0; |
| | | uint8_t motor_flag; |
| | | uint16_t rec_ancpos; |
| | | uint8_t dist_noutenough_count; |
| | | uint8_t ancdist_hist[11]; |
| | | |
| | | void NearPoll(void) |
| | | { |
| | | |
| | | uint32_t temp1,temp2,dw_systime,mindist_slavebaseid; |
| | | static u8 notenoughdist_count=0; |
| | | |
| | | uint32_t final_tx_time; |
| | | u32 start_poll; |
| | | u8 i,j,getsync_flag=0,timeout,get_newdist,pos_nochange=1; |
| | |
| | | outrange_times = 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | mainbase_lost_count=0; |
| | | flag_finalsend=1; |
| | | memcpy(&mainbase_dist,&rx_buffer[DIST_IDX],4); |
| | |
| | | |
| | | flag_getresponse=1; |
| | | //时间同步 |
| | | tmp_time=tmp_time+450; |
| | | tmp_time=tmp_time+450; |
| | | if(tmp_time>999) |
| | | { |
| | | tmp_time-=999; |
| | |
| | | mainbase_id = rec_nearbaseid; |
| | | tag_state = GETNEARMSG; |
| | | trygetnearmsg_times = 0; |
| | | GetNearMsg(); |
| | | } |
| | | #endif |
| | | |
| | |
| | | changemainbase_count++; |
| | | if(changemainbase_count>tag_frequency*2) |
| | | { |
| | | mainbase_id = mindist_slavebaseid; |
| | | tag_state = GETNEARMSG; |
| | | trygetnearmsg_times = 0; |
| | | mainbase_id = mindist_slavebaseid; |
| | | tag_state = GETNEARMSG; |
| | | trygetnearmsg_times = 0; |
| | | GetNearMsg(); |
| | | } |
| | | }else{ |
| | | changemainbase_count = 0; |
| | |
| | | } |
| | | } |
| | | } |
| | | if(get_newdist>2) |
| | | if(get_newdist>=2) |
| | | { |
| | | notenoughdist_count = 0; |
| | | }else{ |
| | | if(notenoughdist_count++>3) |
| | | { |
| | | notenoughdist_count = 0; |
| | | current_slotpos = start_count%max_slotpos; //如果丢失连接超过5次就随机换个时间片 |
| | | tagpoll_sync_sec = current_slotpos/200; |
| | | tagslotpos = current_slotpos%200; |
| | | flag_tagnewpos = 0; |
| | | // tag_state = DISCPOLL; |
| | | } |
| | | } |
| | |
| | | if(nearbaseid_list[i]!=nearbaseid_list2[i]) |
| | | { |
| | | tag_state = GETNEARMSG; |
| | | trygetnearmsg_times = 0; |
| | | nearbaseid_list0[i]=1; |
| | | trygetnearmsg_times = 0; |
| | | nearbaseid_list0[i]=1; |
| | | GetNearMsg(); |
| | | } |
| | | } |
| | | if(pos_nochange) |