From 0401ba0353be795d83dad129a942d892c7f13eb5 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期六, 23 三月 2024 19:51:13 +0800 Subject: [PATCH] 修改同步时间,lora发送长度也会影响同步延迟的参数。 2.增加回复基站随机5个抢占位。 --- Src/application/dw_mbx_tag.c | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Src/application/dw_mbx_tag.c b/Src/application/dw_mbx_tag.c index 4d4d1cd..e31c05a 100644 --- a/Src/application/dw_mbx_tag.c +++ b/Src/application/dw_mbx_tag.c @@ -214,8 +214,8 @@ } if(i==rec_nearbase_num&&taglist_pos==taglist_num)//当基站不在标签列表中,标签也不在基站列表中时,随机找个时间片回复基站。 { - //Anchor_RecNearPoll(rec_nearbase_num+start_time%2); - Anchor_RecNearPoll(rec_nearbase_num); + Anchor_RecNearPoll(rec_nearbase_num+start_time%5); + // Anchor_RecNearPoll(rec_nearbase_num); } } @@ -283,7 +283,9 @@ uint16_t heatbeat_count = 3600; int16_t intheight; #define HEATBEAT_UPDATE_TIME 3600 +#define LORA_REPORT_MAXANC_NUM 7 extern float Height; +u8 tarray[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; void LoraReportPoll(void) { // delay_ms(100); @@ -307,6 +309,25 @@ LoraHeartBeartPoll(); return; } + for(u16 i=0; i<report_ancnum-1; i++) + { + for(u16 j=0; j<report_ancnum-1-i; j++) + { + if(report_ancdist[j]>report_ancdist[j+1]) + { + u16 id,dist; + u8 bat; + id = report_ancid[j]; + dist = report_ancdist[j]; + report_ancid[j] = report_ancid[j+1]; + report_ancdist[j] = report_ancdist[j+1]; + report_ancid[j+1] = id; + report_ancdist[j+1] = dist; + } + } + } + if(report_ancnum>LORA_REPORT_MAXANC_NUM) //考虑lora传输时间,最多发送10个基站数据。 + report_ancnum = LORA_REPORT_MAXANC_NUM; #ifdef USE_GPS lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_GPS; lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+30; @@ -328,23 +349,6 @@ lora_sendbuffer[GPS_SPOWER_IDX] = gps_signalpower; lora_sendbuffer[GPS_CHAFENLINGQI] = gps_chafenlingqi; #endif - for(u16 i=0; i<report_ancnum-1; i++) - { - for(u16 j=0; j<report_ancnum-1-i; j++) - { - if(report_ancdist[j]>report_ancdist[j+1]) - { - u16 id,dist; - u8 bat; - id = report_ancid[j]; - dist = report_ancdist[j]; - report_ancid[j] = report_ancid[j+1]; - report_ancdist[j] = report_ancdist[j+1]; - report_ancid[j+1] = id; - report_ancdist[j+1] = dist; - } - } - } memcpy(&lora_sendbuffer[BAR_HEIGHT_IDX],&bar_height,2); lora_sendbuffer[ANCNUM_IDX] = report_ancnum; memcpy(&lora_sendbuffer[ANCID_IDX],report_ancid,report_ancnum*2); -- Gitblit v1.9.3