From 1b4876fa8c75d9a0f3ffbfdc515a59a776f9dd65 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期五, 19 四月 2024 14:42:27 +0800
Subject: [PATCH] 增加数据上传秒延迟模式,增加远距离通道,测试网关通讯能力模式

---
 Src/application/dw_mbx_tag.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Src/application/dw_mbx_tag.c b/Src/application/dw_mbx_tag.c
index 8fa2247..681e728 100644
--- a/Src/application/dw_mbx_tag.c
+++ b/Src/application/dw_mbx_tag.c
@@ -244,12 +244,15 @@
 u8 seq_num;
 extern u8 wg_lost_count;
 uint16_t wg_report_freq,wg_report_id;
+uint8_t wg_report_sf;
 #define WG_LOST_SWITCH_THRES   3
 #define WG_LOST_NOUWB_COUNT    60
 #define DEFAULT_WG_ID       0xFFFF
+#define DEFAULT_LR_WG_ID    0xFFFE
 u8 lora_jianting_flag = 1;
 void LoraReportFreqPoll(void)
 {
+    wg_state = WG_Lost;
     if(wg_lost_count++>WG_LOST_NOUWB_COUNT)
     {
         lora_jianting_flag = 0;
@@ -257,9 +260,20 @@
         lora_jianting_flag = 1;
     }
     if(wg_state==WG_Lost)
-    {
-        wg_report_id = DEFAULT_WG_ID;
-        wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; //如果丢失链接就进入WG管理信道。
+    {static u8 channel_switch_count = 0;
+        channel_switch_count = 0;
+        if(channel_switch_count++>2)
+        {
+            channel_switch_count = 0;
+            wg_report_id = DEFAULT_LR_WG_ID;
+            wg_report_freq = LR_DATA_CHANNEL_FRQ; //如果丢失链接就进入WG管理信道。
+            wg_report_sf = LR_DATA_CHANNEL_SF;
+            
+        }else{
+            wg_report_id = DEFAULT_WG_ID;
+            wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; //如果丢失链接就进入WG管理信道。
+            wg_report_sf = REPORT_CHANNEL_SF;
+        }
     } else {
         if(wg_lost_count>WG_LOST_SWITCH_THRES)
         {
@@ -301,7 +315,7 @@
     LoraReportFreqPoll();
     flag_getwgresp = 0;
   //  wg_report_freq = REPORT_MANGE_CHANNEL_FRQ;
-    SwitchLoraSettings(wg_report_freq,REPORT_CHANNEL_SF,g_com_map[LORA_POWER]);
+    SwitchLoraSettings(wg_report_freq,wg_report_sf,g_com_map[LORA_POWER]);
    if(heatbeat_count++>HEATBEAT_UPDATE_TIME && WG_Connected == wg_state) //如果心跳包到达上传时间,并且网关处于链接状态,就上传心跳包
     {
         heatbeat_count = 0;

--
Gitblit v1.9.3