Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs
@@ -46,6 +46,9 @@
            }
            new System.Threading.Thread (async () => {
                bool IsRemoteLoadingShow = false;
                try {
                    if (status == 0) {
                        Application.RunOnMainThread (() => {
@@ -75,6 +78,7 @@
                        });
                        bool canRemote = false;
                      
                        //1.如果本地没网关数据,提示WiFiOffline,并且判断是否需要断开远程
                        if (gateWayList == null || gateWayList.Count == 0) {
@@ -111,6 +115,9 @@
                                    if (status == 2) {
                                        //var result = Control.ControlBytesSendHasReturn (Command.ReadGateway, common.SubnetID, common.DeviceID, new byte [] { (byte)new Random ().Next (255), (byte)new Random ().Next (255) });
                                        #region
                                        //开始本地搜索网关...
                                        MainPage.LoadingStart ("Searching local gateway...");
                                        var control = new Control ();
                                        control.Send (new Target () {
                                            IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000),
@@ -133,10 +140,19 @@
                                                    UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus;
                                                    MainPage.Loading.Hide ();
                                                });
                                                //搜索成功,启用本地连接
                                                MainPage.AddTip ("Gateway searched successfully, enable local connection.");
                                                Shared.SimpleControl.Phone.UserMiddle.ReadAllDeviceStatus ();
                                                await SmartHome.MqttCommon.DisConnectRemoteMqttClient ();
                                                return;
                                            } else {
                                            }
                                        } else {
                                            //搜索失败,启用远程连接
                                            MainPage.AddTip ("Gateway cannot be searched locally.");
                                        }
                                    } else {
                                        break;
@@ -153,12 +169,17 @@
                                if (UserConfig.Instance.CheckHomeGateways ()) {
                                    if (!string.IsNullOrEmpty (UserConfig.Instance.CurrentRegion.HomeGateways [0].GatewayUniqueId)) {
                                        // 5.1能远程,显示CloudUnlink状态,IsRemote设为true开始远程
                                        MainPage.AddTip ("Starting remote connection mode...");
                                        //MainPage.AddTip ("Please wait, starting remote connection...");
                                        //MainPage.LoadingStart ("Please wait, starting remote connection...");
                                        Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink);
                                        MainPage.LoadingTipShow ("Please wait, starting remote connection...");
                                        CommonPage.IsRemote = true;
                                        SmartHome.MqttCommon.IsGatewayOnline = false;
                                        //await SmartHome.MqttCommon.StartCloudMqtt ();
                                        IsRemoteLoadingShow = true;
                                        //重置参数状态
                                        SmartHome.MqttCommon.InitState ();
                                        Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink);
                                    }
                                }
                            }
@@ -183,6 +204,12 @@
                    Utlis.WriteLine ("CheckLinkRemote : " + ex.ToString ());
                } finally {
                    isConnectiong = false;
                    //if (!IsRemoteLoadingShow) {
                    //    Application.RunOnMainThread (() => {
                    //        MainPage.Loading.Hide ();
                    //    });
                    //}
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                    });
@@ -190,7 +217,7 @@
            }) { IsBackground = true }.Start ();
        }
        //static bool IsRemoteLoadingShow = false;
        /// <summary>
        /// 关闭远程连接模式,并断开MQTT