| | |
| | | { |
| | | if (gatewayDeicve.Type == DeviceType.OnePortMqttFR) { |
| | | |
| | | Console.WriteLine ("Assign OnePortMqttFR,HDL MQTT"); |
| | | Utlis.WriteLine ("Assign OnePortMqttFR,HDL MQTT"); |
| | | //RemoteSetting (); |
| | | RemoteSettingWithHDLMQTT (); |
| | | } else { |
| | | Console.WriteLine ("Assign OnePortWirelessFR"); |
| | | Utlis.WriteLine ("Assign OnePortWirelessFR"); |
| | | RemoteSettingWithOldDevice (); |
| | | //RemoteSettingWithMQTT (); |
| | | } |
| | |
| | | if (common.Type == DeviceType.MusicModel) |
| | | continue; |
| | | if (common.isMixBox) { |
| | | Console.WriteLine ("IsMixBox"); |
| | | Utlis.WriteLine ("IsMixBox"); |
| | | continue; |
| | | } |
| | | countDevcie++; |
| | |
| | | btnDelDevice.Parent.RemoveFromParent (); |
| | | }); |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | // } |
| | | // } |
| | | // } catch (Exception ex) { |
| | | // Console.WriteLine ("Cinfig Read Device Loop Info " + ex.Message); |
| | | // Utlis.WriteLine ("Cinfig Read Device Loop Info " + ex.Message); |
| | | // } |
| | | //}); |
| | | } |
| | |
| | | //这里搜索设备,直到完成就退出 |
| | | readDevice (); |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } |
| | | Application.RunOnMainThread (action); |
| | | }) { IsBackground = true }.Start (); |
| | |
| | | ms.WriteByte (common.SubnetID); |
| | | ms.WriteByte (common.DeviceID); |
| | | } |
| | | Console.WriteLine ("搜索非网关设备,网络地址是:" + CommonPage.EndPoint.ToString ()); |
| | | Utlis.WriteLine ("搜索非网关设备,网络地址是:" + CommonPage.EndPoint.ToString ()); |
| | | var control = new Control (); |
| | | control.Send (new Target () { |
| | | IPEndPoint = CommonPage.EndPoint, |
| | |
| | | BindGatewaysNew (); |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | |
| | | //读取一端口交换机、无线网关的配置信息 |
| | | gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); |
| | | |
| | | gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName; |
| | | gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName; |
| | | gatewayDeicve.Remote_UserName = "Admin"; |
| | | gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.ID; |
| | | //gatewayDeicve.Remote_Password = "85521566"; |
| | | byte [] ggn = new byte [20]; |
| | | byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_GroupName); |
| | | gatewayDeicve.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); |
| | | Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length); |
| | | |
| | | byte [] gpn = new byte [20]; |
| | | byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_ProjectName); |
| | | Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length); |
| | | |
| | | byte [] gun = new byte [8]; |
| | | byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_UserName); |
| | | Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length); |
| | | |
| | | byte [] gpw = new byte [8]; |
| | | byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_Password); |
| | | Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length); |
| | | |
| | | |
| | | gatewayBytes [0] = TYPEHdlMQTT;//HDL MQTT |
| | | Array.Copy (ggn, 0, gatewayBytes, 1, 20); |
| | | Array.Copy (gpn, 0, gatewayBytes, 21, 20); |
| | | Array.Copy (gun, 0, gatewayBytes, 41, 8); |
| | | Array.Copy (gpw, 0, gatewayBytes, 49, 8); |
| | | //1.修改用户名信息 |
| | | Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, gatewayBytes); |
| | | ////2.读取一次管理信息 |
| | | //byte [] adminBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayAdminInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); |
| | | ////3.修改管理信息 |
| | | //if (SetGateWayAdminInfo (adminBytes)) { |
| | | // //4.写配置成功后下一步操作 |
| | | // GatewaySettingSucceeded (); |
| | | ////读取一端口交换机、无线网关的配置信息 |
| | | //gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); |
| | | //if (gatewayBytes == null) { |
| | | // //读取一端口交换机、无线网关的配置信息失败 |
| | | // new Alert ("", "Read gateway configuration failed!", "Close").Show (); |
| | | // return; |
| | | //} |
| | | |
| | | //2.修改管理信息 |
| | | if (SetGateWayAdminInfo ()) { |
| | | //3.写配置成功后下一步操作 |
| | | GatewaySettingSucceeded (); |
| | | |
| | | //1.修改用户名信息 和修改连接模式 |
| | | if (SetGateWayModelInfo()) { |
| | | //2.修改管理信息 |
| | | if (SetGateWayAdminInfo ()) { |
| | | //3.写配置成功后下一步操作 |
| | | GatewaySettingSucceeded (); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | Application.RunOnMainThread (() => { |
| | | //修改网关连接模式失败 |
| | | new Alert ("", "Failed to modify gateway connection mode!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | |
| | | } |
| | | }); |
| | | //Room.InitAllRoom (); |
| | | } |
| | | |
| | | bool SetGateWayModelInfo () { |
| | | byte [] gatewayBytes = new byte [60]; |
| | | gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName; |
| | | gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName; |
| | | gatewayDeicve.Remote_UserName = "Admin"; |
| | | gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.ID; |
| | | //gatewayDeicve.Remote_Password = "85521566"; |
| | | byte [] ggn = new byte [20]; |
| | | byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_GroupName); |
| | | gatewayDeicve.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); |
| | | Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length); |
| | | |
| | | byte [] gpn = new byte [20]; |
| | | byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_ProjectName); |
| | | Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length); |
| | | |
| | | byte [] gun = new byte [8]; |
| | | byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_UserName); |
| | | Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length); |
| | | |
| | | byte [] gpw = new byte [8]; |
| | | byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_Password); |
| | | Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length); |
| | | |
| | | |
| | | gatewayBytes [0] = TYPEHdlMQTT;//HDL MQTT |
| | | Array.Copy (ggn, 0, gatewayBytes, 1, 20); |
| | | Array.Copy (gpn, 0, gatewayBytes, 21, 20); |
| | | Array.Copy (gun, 0, gatewayBytes, 41, 8); |
| | | Array.Copy (gpw, 0, gatewayBytes, 49, 8); |
| | | byte [] backBytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, gatewayBytes); |
| | | return CheckIsSuccessfulWithBytes (backBytes, "Failed to modify gateway connection mode."); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | MainPage.LoginUser.LastTime = DateTime.Now; |
| | | Application.RunOnMainThread (() => { |
| | | bodyView.RemoveAll (); |
| | | //MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; |
| | | UserMiddle.Init (true); |
| | | MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; |
| | | UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus; |
| | | }); |
| | | |
| | | //Utlis.ShowAppLinkStatus (AppLinkStatus.WiFi); |
| | | |
| | | } |
| | | |
| | |
| | | // } |
| | | |
| | | // } catch (Exception ex) { |
| | | // Console.WriteLine (ex.Message); |
| | | // Utlis.WriteLine (ex.Message); |
| | | // Application.RunOnMainThread (() => { |
| | | // new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | // }); |