| | |
| | | |
| | | static bool isConnectiong = false; |
| | | static DateTime mFlagDateTime; |
| | | static bool upLoadLink = true; |
| | | /// <summary> |
| | | /// 检测/连接远程 |
| | | /// </summary> |
| | |
| | | MainPage.LoadingStart (Language.StringByID (R.MyInternationalizationString.SearchingGatewayLocally)); |
| | | |
| | | var control = new Control (); |
| | | |
| | | UserConfig.Instance.IsLocalEncrypt = false; |
| | | control.Send (new Target () { |
| | | IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000), |
| | | Command = Command.ReadGateway, |
| | |
| | | }, SendCount.Three, true, true); |
| | | var result = control.UsefulBytes; |
| | | |
| | | |
| | | #endregion |
| | | if (result != null) { |
| | | //没有配置通讯秘钥时,写入秘钥 |
| | | if (!string.IsNullOrEmpty (UserConfig.Instance.LocalEncryptKey) && !UserConfig.Instance.IsLocalEncrypt) { |
| | | byte [] AseKeyBytes = UserConfig.Instance.GenerateLocalEncryptionKey (); |
| | | byte [] sendBytes = new byte [17]; |
| | | sendBytes [0] =(byte)1 ; //0:不加密 1:加密 |
| | | Array.Copy (AseKeyBytes, 0, sendBytes, 1, 16); |
| | | byte [] backBytes = Control.ControlBytesSendHasReturn (Command.SetGateWayLocalEncryption, SmartHome.MqttCommon.GatewayCommon.SubnetID, SmartHome.MqttCommon.GatewayCommon.DeviceID, sendBytes); |
| | | } |
| | | |
| | | |
| | | var mac0 = CommonPage.byteToHex16 (result [5]) + "." + CommonPage.byteToHex16 (result [6]) + "." + CommonPage.byteToHex16 (result [7]) + "." + CommonPage.byteToHex16 (result [8]) + "." + CommonPage.byteToHex16 (result [9]) + "." + CommonPage.byteToHex16 (result [10]) + "." + CommonPage.byteToHex16 (result [11]) + "." + CommonPage.byteToHex16 (result [12]); |
| | | if (SmartHome.MqttCommon.GatewayCommon.MAC.Replace (".", "").Replace (":", "").ToUpper () == mac0.Replace (".", "").Replace (":", "").ToUpper ()) { |
| | | //搜索成功,启用本地连接 |
| | |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | #if DEBUG |
| | | //upLoadLink = true; |
| | | #endif |
| | | |
| | | //平台迁移数据处理 wxr 2022-06-14 13:37:49 |
| | | if (!UserConfig.Instance.CurrentRegion.indiaIsAsyncDeviceMark) { |
| | | MigrateBean bean = new MigrateBean (); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | //var dd = bean.GetTimerBackupBean (); |
| | | //bean.TimerBakeupFileDetailedInformation (dd.id); |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); |
| | | }); |
| | | //1.获取迁移备份 |
| | | var migrateBackup = bean.GetMigrateBackupBean (); |
| | | if (migrateBackup != null) { |
| | | //2.下载备份 |
| | | bean.UserBakeupFileDetailedInformation (migrateBackup.id); |
| | | } |
| | | |
| | | } catch { |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | }); |
| | | |
| | | ////不是远程 并且本地搜索不到匹配的网关就提示禁止本地发送 |