JLChen
2020-01-12 ac2ee45fadc64fe840bbba6264df3ca4622adb15
Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs
@@ -101,9 +101,12 @@
                                        }
                                        var aesDecryptTopic = e.ApplicationMessage.Topic;
                                        var aesDecryptPayload = e.ApplicationMessage.Payload;
                                        //Console.WriteLine ("Topic={0}", aesDecryptTopic);
                                        Console.WriteLine ("Topic={0}", aesDecryptTopic);
                                        if (aesDecryptTopic == $"NotifyBusGateWayInfoChagne/{CurRemoteMACInfo.md5_mac_string}") {//网关上线,需要更新aeskey
                                        //if (aesDecryptTopic == $"NotifyBusGateWayInfoChagne/{CurRemoteMACInfo.md5_mac_string}") {//网关上线,需要更新aeskey
                                        //2020-01-11 修改订阅主题地址
                                        if (aesDecryptTopic == $"BusGateWayToClient/{CurRemoteMACInfo.macMark}/NotifyGateWayInfoChange") {//网关上线,需要更新aeskey
                                            Console.WriteLine ("网关上线,需要更新aeskey");
                                            //----第二步:读取账号下面的网关列表
                                            var gatewayListUrl = $"{MainPage.RequestHttpsHostMqtt}/Center/Center/GetGatewayPagger"; //App、Buspro软件登录后获取网关列表 http 请求
@@ -251,7 +254,7 @@
                                requestObj3.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
                                requestObj3.ReqDto.HomeId = UserConfig.Instance.CurrentRegion.Id;
                                requestObj3.ReqDto.PageSetting.Page = 1;
                                requestObj3.ReqDto.PageSetting.PageSize = 999;
                                requestObj3.ReqDto.PageSetting.PageSize = 10;
                                string urlHead = MainPage.RequestHttpsHost;
                                if (requestObj3.IsOtherAccountCtrl) {
                                    urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
@@ -264,14 +267,8 @@
                                var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead);
                                if (revertObj3.StateCode.ToUpper() == "SUCCESS") {
                                    var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ());
                                    var gatewayList = infoResult.PageData;
                                    if (gatewayList != null && gatewayList.Count > 0) {
                                        if (UserConfig.Instance.CheckHomeGateways ()) {
                                            UserConfig.Instance.CurrentRegion.HomeGateways [0].GatewayUniqueId = gatewayList [0].GatewayUniqueId;
                                            UserConfig.Instance.SaveUserConfig ();
                                            Console.WriteLine ("Remote mqtt get Region MAC : " + gatewayList [0].GatewayUniqueId);
                                        }
                                    }
                                    //2020-01-11
                                    UserConfig.Instance.SetNowHomeGateways (infoResult.PageData);
                                } else {
                                    //提示错误
                                    //GetSingleHomeGatewayPagger
@@ -419,9 +416,11 @@
                        CurRemoteMACInfo.md5_mac_string = builder.ToString ().ToUpper ();
                    }
                    topicName = $"/NotifyBusGateWayInfoChagne/{CurRemoteMACInfo.md5_mac_string}";
                    //topicName = $"/NotifyBusGateWayInfoChagne/{CurRemoteMACInfo.md5_mac_string}";
                    //2020-01-11 修改订阅主题地址
                    topicName = $"BusGateWayToClient/{CurRemoteMACInfo.macMark}/NotifyGateWayInfoChange";
                    //if (remoteIsConnected) {
                        try {
                    try {
                            await RemoteMqttClient.SubscribeAsync (topicName);
                        } catch (Exception e) {
                            await DisConnectRemoteMqttClient (e.Message);