From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 25 七月 2024 17:25:59 +0800 Subject: [PATCH] 2024年07月25日17:24:45 --- HDL_ON/DAL/Mqtt/MqttClient.cs | 45 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 34 insertions(+), 11 deletions(-) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index f4e129f..cea69ec 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -13,6 +13,8 @@ using HDL_ON.UI; using HDL_ON.DAL.Server; using HDL_ON; +using Newtonsoft.Json; +using System.Collections.Generic; namespace HDL_ON.DAL.Mqtt { @@ -111,7 +113,7 @@ { MqttInfoConfig.Current.IfGetMqttInfoSuccess = false; } - Control.Ins.GatewayOnline_Cloud = Control.Ins.GatewayOnline_Local = false; + //Control.Ins.GatewayOnline_Cloud = Control.Ins.GatewayOnline_Local = false; await DisConnectRemoteMqttClient(s); } @@ -145,6 +147,7 @@ await StartCloudMqtt(); await SubscribeTopics(); + } catch { } } @@ -158,6 +161,7 @@ public static void InitState() { IfNeedReadAllDeviceStatus = true; + Common.ApiUtlis.Ins.hadInternet = true; StartCloudMqtt(); } @@ -337,7 +341,13 @@ public static async Task StartCloudMqtt() { //娌℃湁缃戠粶鐨勭姸鎬佷笅灏濊瘯涓�涓嬭繛鎺qtt 锛屽畨鍗撶殑缃戠粶鐘舵�佸彉鍖栫洃鍚湁寮傚父锛屼慨鏀瑰簳灞傞夯鐑� - if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1) + if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1 ) + { + return; + } + + + if (!Common.ApiUtlis.Ins.hadInternet) { return; } @@ -363,6 +373,26 @@ await Task.Factory.StartNew((Func<Task>)(async () => { try { + try + { + //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁 + var dataList = new List<GlobalRegionListRes>(); + var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); + var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3); + if (revertObj == null || revertObj.Code != StateCode.SUCCESS) + { + Common.ApiUtlis.Ins.hadInternet = false; + return; + } + else + { + Common.ApiUtlis.Ins.hadInternet = true; + } + } + catch + { + } + #region 鍒濆鍖栬繙绋婱qtt RemoteMqttIsConnecting = true; RemoteMqttClient = new MqttFactory().CreateMqttClient(); @@ -549,7 +579,7 @@ { var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); var revString = Encoding.UTF8.GetString(bytes); - MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); + //MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); Control.Ins.UpdataFunctionStatus(revString, null, true); //Control.Ins.MsgInfoList.Add($"mqtt 鐘舵�佹洿鏂�:{revString}"); //Control.Ins.MsgInfoList.Add(revString + "\r\n"); @@ -830,16 +860,11 @@ /// </summary> static void ReceiveNotifySqueezeAsync(string mMes) { -#if DEBUG - //return; -#endif if (mMes == PushSignStr) return;//鏄嚜宸辩殑鐧诲綍鎺ㄩ�佷笉澶勭悊//鎴栬�呭綋鍓嶄笉鏄繙绋嬮摼鎺ョ姸鎬� //娴嬭瘯璐﹀彿锛屼笉鎸や笅绾� switch (UserInfo.Current.userMobileInfo) { - case "18316672920": case "15626203746": - case "464027401@qq.com": return; } @@ -890,9 +915,7 @@ static void SendPushSignOut() { byte[] message = Encoding.UTF8.GetBytes(PushSignStr); -#if DEBUG MqttRemoteSend(message, 4); -#endif } /// <summary> @@ -980,7 +1003,7 @@ MqttInfoConfig.Current.mMqttInfo = mqttInfoRequestResult_Obj; - await MQTTConnectAsync(); + //await MQTTConnectAsync(); //1.鍒ゆ柇鏄惁缁戝畾浜嗙綉鍏筹紝鑾峰彇缃戝叧杩滅▼杩炴帴鐨勫姞瀵咾EY //if (DB_ResidenceData.Instance.CheckWhetherGatewayIsBound()) { -- Gitblit v1.8.0