zhyinch
2021-10-15 101cfeb2638fe4539b3e0040a99cc045e7d2f651
Src/application/dw_app.c
@@ -70,7 +70,7 @@
#define FINAL_MSG_TS_LEN 4
#define STARTPOLL  REGPOLL//#define SWITCHBASE_DIST
//#define SWITCHBASE_ZHUANDIAN
#define SWITCHBASE_ZHUANDIAN
#define SWITCHBASE_DIST
enum enumtagstate
{
@@ -675,7 +675,9 @@
//         tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;
   }
}
#define MAX_NEARBASE_ANCNUM 11
u16 rec_maxrangelen,rec_anc_signalpower[MAX_NEARBASE_ANCNUM];
u8 outrange_times;
void NearPoll(void)
{
   
@@ -705,19 +707,21 @@
   tx_near_msg[NEARBASENUM_INDEX] = nearbase_num;
   memcpy(&tx_near_msg[NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2);
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*2],&nearbase_distlist,nearbase_num*4+4);
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*6+4],&rec_anc_signalpower,nearbase_num*2+2);
    
    if(intheight!=0)
    intheight+=g_com_map[HEIGHTOFFEST_INDEX];
    
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*6+4],&intheight,2);
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*8+6],&intheight,2);
   tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_POLL;   
   
   tx_near_msg[NEARP_TAGFREQ_INDEX] = tag_frequency;   
   tx_near_msg[NEARP_TAGSLOTPOS_INDEX] = tagslotpos;   
   memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2);   
   dwt_writetxdata(28+6*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
   dwt_writetxfctrl(28+6*nearbase_num, 0);//设置超宽带发送数据长度
   dwt_writetxdata(29+8*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
   dwt_writetxfctrl(29+8*nearbase_num, 0);//设置超宽带发送数据长度
   dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置
   
//    for(i=0;i<nearbase_num+1;i++)
@@ -799,6 +803,21 @@
                                    base_mindist = temp_dist;
                           if((rx_buffer[MOTORSTATE_INDEX]&0xf)!=3)
                              motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf;
                                    if(frame_len==28)
                                     {
                                         memcpy(&rec_maxrangelen,&rx_buffer[MAXRANGE_DISTANCE],2);
                                         memcpy(&rec_anc_signalpower[0],&rx_buffer[ANC_SIGNALPOWER],2);
                                         if(mainbase_dist>rec_maxrangelen&&mainbase_dist>0&&rec_maxrangelen!=0)
                                         {
                                             if(outrange_times++>OUTRANGE_RESTARTTIMES)
                                             {
                                               // tag_state = STARTPOLL;
                                             }
                                         }else{
                                             outrange_times = 0;
                                         }
                                     }
                           rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4;
                           
                           mainbase_lost_count=0;
@@ -833,6 +852,8 @@
                           rec_nearbasepos=FindNearBasePos(rec_nearbaseid);                           
                           exsistbase_list[rec_nearbasepos]=KEEP_TIMES;
                           memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
                                    if(frame_len==28)
                                    memcpy(&rec_anc_signalpower[rec_nearbasepos+1],&rx_buffer[ANC_SIGNALPOWER],2);
                           memcpy(&nearbase_switchdistlist[rec_nearbasepos],&rx_buffer[NR_NEARSWITCH_DISTANCE],2);
                           nearbase_distlist[rec_nearbasepos+1]=temp_dist;   //   nearbase_distlist[1]对应   rec_nearbaseid[0]的距离               
                           final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts);