| | |
| | | //这个界面的背景需要白色 |
| | | bodyFrameLayout.BackgroundColor = UI.CSS.CSS_Color.MainBackgroundColor; |
| | | |
| | | #if __IOS__ |
| | | #endif |
| | | #if __Android__ |
| | | //添加接收蓝牙反馈的事件 |
| | | HdlAndroidBluetoothLogic.Current.AddReceiveEvent(this.BluetoothReceiveEvent); |
| | | #endif |
| | | HdlBluetoothLogic.Current.AddReceiveEvent(this.BluetoothReceiveEvent); |
| | | |
| | | //添加云端反馈事件 |
| | | HdlCloudReceiveLogic.Current.AddCloudReceiveEvent("AddMiniRemoteControlDirection4Page", this.CloudReceiveEvent); |
| | | |
| | |
| | | btnReDo.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //重新初始化中部信息 |
| | | this.InitMiddleFrame(); |
| | | this.CloseForm(); |
| | | var form = new AddMiniRemoteControlDirection2Page(); |
| | | form.AddForm(this.wifiName, this.wifiPsw); |
| | | }; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | private void SendAccountAndPswToBluetooth() |
| | | { |
| | | #if __IOS__ |
| | | #endif |
| | | #if __Android__ |
| | | //获取发送到蓝牙的数据 |
| | | var sendData = this.GetSendToBluetoothData(); |
| | | //不等待 |
| | | HdlAndroidBluetoothLogic.Current.SendData(sendData); |
| | | #endif |
| | | HdlBluetoothLogic.Current.SendData(sendData); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 红外宝相关方法_____________________ |
| | | |
| | | /// <summary> |
| | | /// 检测是否是新的红外宝 |
| | | /// </summary> |
| | | /// <param name="pushEnum">推送枚举</param> |
| | | /// <param name="i_data">推送的数据</param> |
| | | /// <returns></returns> |
| | | private bool CheckIsNewMiniRemoteControl(CloudPushEnum pushEnum, string i_data) |
| | | { |
| | | if (pushEnum != CloudPushEnum.A新设备上报) { return false; } |
| | | |
| | | try |
| | | { |
| | | var strSpk = string.Empty; |
| | | //转为json |
| | | var json = Newtonsoft.Json.Linq.JObject.Parse(i_data); |
| | | var linqArry = json["objects"] as Newtonsoft.Json.Linq.JArray; |
| | | if (linqArry != null) |
| | | { |
| | | //数组类型 |
| | | if (linqArry.Count == 0) { return false; } |
| | | strSpk = linqArry[0]["spk"].ToString(); |
| | | } |
| | | else |
| | | { |
| | | //非数组类型 |
| | | strSpk = json["objects"]["spk"].ToString(); |
| | | } |
| | | if (strSpk != Entity.SPK.IrModule) |
| | | { |
| | | //如果不是红外宝的话 |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | catch { return false; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新红外宝信息 |
| | | /// </summary> |
| | | private void RefreshMiniRemoteControlInfo() |
| | | { |
| | | var pra = new Dictionary<string, object>(); |
| | | pra.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID); |
| | | |
| | | var requestJson = DAL.Server.HttpUtil.GetSignRequestJson(pra); |
| | | DAL.Server.HttpUtil.RequestHttpsPostFroHome(DAL.Server.NewAPI.Api_Post_GetDevcieList, requestJson); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// <param name="i_data">推送的内容</param> |
| | | private void CloudReceiveEvent(CloudPushEnum pushEnum, string i_data) |
| | | { |
| | | if (pushEnum != CloudPushEnum.A新设备上报) { return; } |
| | | //检测是否是新的红外宝 |
| | | if (this.CheckIsNewMiniRemoteControl(pushEnum, i_data) == false) |
| | | { |
| | | return; |
| | | } |
| | | //刷新红外宝信息 |
| | | this.RefreshMiniRemoteControlInfo(); |
| | | |
| | | //接收到就移除这个事件 |
| | | HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); |
| | |
| | | { |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //300秒超时 |
| | | int timeout = 300; |
| | | //360秒超时 |
| | | int timeout = 360; |
| | | while (this.timeoutThreadActivity == false && this.Parent != null) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | |
| | | public override void CloseFormBefore() |
| | | { |
| | | //摧毁蓝牙 |
| | | #if __IOS__ |
| | | #endif |
| | | #if __Android__ |
| | | HdlAndroidBluetoothLogic.Current.Dispone(); |
| | | #endif |
| | | HdlBluetoothLogic.Current.Dispone(); |
| | | HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); |
| | | |
| | | base.CloseFormBefore(); |