yincheng.zhong
2024-04-19 1b4876fa8c75d9a0f3ffbfdc515a59a776f9dd65
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;