From cdcf6a128503b3a4fc0dcc4f86ec63a3ab8a59b5 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期三, 09 十二月 2020 21:42:40 +0800 Subject: [PATCH] V2.13 修改丢包重连机制 --- Src/application/dw_app.c | 59 ++++++++++++++++++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index 22a43b4..6d6e1a9 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -552,7 +552,7 @@ { memcpy(&minid, &rx_buffer[ANCHOR_ID_IDX], 4); tag_state=GETNEARMSG; - trygetnearmsg_times=5; + trygetnearmsg_times=10*tag_frequency; mindist=temp_dist; } if(result==0) @@ -576,7 +576,7 @@ } if(getsync_flag==0) { - tagslotpos--; +// tagslotpos--; if(tagslotpos==0||tagslotpos>max_slotpos) { tagslotpos=max_slotpos; @@ -584,7 +584,7 @@ tyncpoll_time=(tagslotpos-1)*slottime; } mainbase_id=minid; - //mainbase_id = 0x1; +// mainbase_id = 0x9804; } u8 nearmsg_mainbase=0,rec_tagpos_emptylist[32],mainbase_type;; void GetNearMsg(void) @@ -628,7 +628,7 @@ tag_state=NEARPOLL; } }else{ - tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; +// tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; } } extern u8 userkey_state; @@ -777,7 +777,7 @@ memcpy(&nearbase_switchdistlist[rec_nearbasepos],&rx_buffer[NR_NEARSWITCH_DISTANCE],2); nearbase_distlist[rec_nearbasepos]=temp_dist; final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts); - if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist!=0) + if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist>0) { mainbase_id = rec_nearbaseid; tag_state = GETNEARMSG; @@ -799,10 +799,10 @@ dwt_forcetrxoff(); dwt_write32bitreg(SYS_STATUS_ID,SYS_STATUS_RXFCG| SYS_STATUS_ALL_RX_ERR); j=0; - if(exsistbase_list[0]==0) - { +// if(exsistbase_list[0]==0) +// { // SetNextPollTime(tagslotpos); - } +// } // tyncpoll_time=0; // next_nearbase_num=0; // for(i=0;i<nearbase_num;i++) @@ -852,10 +852,10 @@ // mainbase_id = true_nearbase_idlist[0]; // tag_state = GETNEARMSG; // } -// if(mainbase_lost_count>3) -// { -// tag_state = DISCPOLL; -// } + if(mainbase_lost_count>10*tag_frequency) + { + tag_state = STARTPOLL; + } // for (i=0;i<nearbase_num;i++) // { // if(nearbaseid_list[i]==0) @@ -881,22 +881,22 @@ // { // nearbase_distlist[i]=0x1ffff; // } -// if(para_update) -// { -// uint8_t pack_length = 0,pack_index = 0,pack_msgtype = 0; -// pack_msgtype = rec_remotepara[0]; -// pack_index = rec_remotepara[1]; -// pack_length = rec_remotepara[2]; -// if(pack_msgtype==2) -// { -// memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length); -// //返回一个error状态 -// //SendComMap(pack_datalen,pack_index); -// save_com_map_to_flash(); -// delay_ms(100); -// NVIC_SystemReset(); -// } -// } + if(para_update) + { + uint8_t pack_length = 0,pack_index = 0,pack_msgtype = 0; + pack_msgtype = rec_remotepara[0]; + pack_index = rec_remotepara[1]; + pack_length = rec_remotepara[2]; + if(pack_msgtype==2) + { + memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length); + //返回一个error状态 + //SendComMap(pack_datalen,pack_index); + save_com_map_to_flash(); + delay_ms(100); + NVIC_SystemReset(); + } + } dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG); HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET); @@ -988,6 +988,7 @@ id = dwt_readdevid() ; while (DWT_DEVICE_ID != id) { + // Dw1000_Init(); id = dwt_readdevid() ; } switch(tag_state) @@ -1009,7 +1010,7 @@ LED_LG_OFF; if(trygetnearmsg_times==0) { - tag_state = DISCPOLL; + tag_state = STARTPOLL; } break; case NEARPOLL: -- Gitblit v1.9.3