From c1e6196d3da930a82f12313bce04205b3488f7f1 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期日, 24 三月 2024 09:22:59 +0800
Subject: [PATCH] Merge branch '免布线标签-lora-泰斗GPS' of http://47.108.70.204:60062/r/XRange_Tag into 免布线标签-lora-泰斗GPS

---
 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