| | |
| | | foreach (var bin in usefullBytes) { |
| | | pushBytesString += bin + ","; |
| | | } |
| | | Console.WriteLine (pushBytesString); |
| | | Utlis.WriteLine (pushBytesString); |
| | | #endif |
| | | if (DeviceList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) { |
| | | return; |
| | |
| | | continue; |
| | | } |
| | | DeviceType deviceType_wireless = (DeviceType)(usefullBytes [i] * 256 + usefullBytes [i + 1]); |
| | | Console.WriteLine (deviceType_wireless.ToString ()); |
| | | Utlis.WriteLine (deviceType_wireless.ToString ()); |
| | | if (noRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") { |
| | | byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (deviceType_wireless.ToString () + "-" + subnetID.ToString () + "-" + deviceID.ToString ()); |
| | | byte [] newddd = new byte [20]; |
| | |
| | | } |
| | | break; |
| | | case Command.SetSingleLightACK: |
| | | Console.WriteLine ("Command.SetSingleLightACK"); |
| | | //Utlis.WriteLine ($"Command.SetSingleLightACK: subnetID:{subnetID} deviceID:{deviceID} 回路:{usefullBytes [0]}"); |
| | | //Utlis.WriteLine ("Command.SetSingleLightACK"); |
| | | foreach (var room in Room.Lists) { |
| | | var common = room.DeviceList.Find ((obj) => obj.CommonLoopID == subnetID.ToString () + "_" + deviceID.ToString () + "_" + usefullBytes [0].ToString ()); |
| | | if (common != null) { |
| | |
| | | hadBeUpdate = false; |
| | | (common as LightDimming).CurrentBrightness = usefullBytes [2]; |
| | | } else if (common.Type == DeviceType.FanModule) { |
| | | //if ((common as FanModule).Switch == usefullBytes [2]) { |
| | | // hadBeUpdate = false; |
| | | //} |
| | | (common as FanModule).Switch = usefullBytes [2]; |
| | | if (usefullBytes [2] != 0) |
| | | (common as FanModule).WindSpeed = usefullBytes [2]; |
| | | |
| | | //(common as FanModule).Switch = usefullBytes [2]; |
| | | } else if (common.Type == DeviceType.LightMixSwitch) { |
| | | if ((common as LightMixSwitch).CurrentBrightness == usefullBytes [2]) |
| | | hadBeUpdate = false; |
| | |
| | | if (!string.IsNullOrEmpty (room.Name)) |
| | | UserDeviceToLight.UpdateBrighingCount (updateFlag); |
| | | if (hadBeUpdate) { |
| | | |
| | | UserRoom.UpdataDeviceStatus (common); |
| | | UserLightPage.UpdateStatus (updateFlag, usefullBytes [2]); |
| | | UserDeviceToLight.UpdateStatus (updateFlag, usefullBytes [2]); |
| | |
| | | |
| | | |
| | | |
| | | int dddd = usefullBytes [0] & 0x3F; |
| | | int dddd = usefullBytes [0] & 0x3F; |
| | | |
| | | // 0xXX:公司内部协议对应的序号 |
| | | // common.Type:对应的是编辑软件的序号(没有一一对应,是为了将相近的调整在一起,方便客户使用) |
| | |
| | | case "DISPMODE": |
| | | if (7 <= backResult [1].Length) { |
| | | music.playMode = int.Parse (backResult [1].Substring (6, 1)); |
| | | System.Console.WriteLine ("DISPMODE=====" + music.playMode); |
| | | Utlis.WriteLine ("DISPMODE=====" + music.playMode); |
| | | } |
| | | break; |
| | | } |
| | |
| | | //}); |
| | | #endregion |
| | | break; |
| | | case DeviceType.OnePortMqttFR: |
| | | #region |
| | | OnePortMqttFR onePortMqttFR = new OnePortMqttFR (); |
| | | string mqttFRPath = "Equipment_" + typeof (OnePortMqttFR).Name + "_" + subnetID + "_" + deviceID; |
| | | var bytesmqttFR = IO.FileUtils.ReadFile (mqttFRPath); |
| | | if (bytesmqttFR.Length > 1) { |
| | | onePortMqttFR = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortMqttFR> (MyEncodingUTF8.GetString (bytesmqttFR)); |
| | | } |
| | | onePortMqttFR.SubnetID = subnetID; |
| | | onePortMqttFR.DeviceID = deviceID; |
| | | onePortMqttFR.ChNumberCount = usefullBytes [4]; |
| | | onePortMqttFR.MAC = byteToHex16 (usefullBytes [5]) + "." + byteToHex16 (usefullBytes [6]) + "." + byteToHex16 (usefullBytes [7]) + "." + byteToHex16 (usefullBytes [8]) + "." + byteToHex16 (usefullBytes [9]) + "." + byteToHex16 (usefullBytes [10]) + "." + byteToHex16 (usefullBytes [11]) + "." + byteToHex16 (usefullBytes [12]); |
| | | onePortMqttFR.Name = MyEncodingGB2312.GetString (usefullBytes, 13, 20).Trim ('\0');//============= |
| | | onePortMqttFR.IPAddress = usefullBytes [33] + "." + usefullBytes [34] + "." + usefullBytes [35] + "." + usefullBytes [36]; |
| | | onePortMqttFR.RouteIPAddress = usefullBytes [37] + "." + usefullBytes [38] + "." + usefullBytes [39] + "." + usefullBytes [40]; |
| | | onePortMqttFR.IPMAC = usefullBytes [41] + "." + usefullBytes [42] + "." + usefullBytes [43] + "." + usefullBytes [44] + "." + usefullBytes [45] + "." + usefullBytes [46]; |
| | | onePortMqttFR.SubnetMask = usefullBytes [47] + "." + usefullBytes [48] + "." + usefullBytes [49] + "." + usefullBytes [50]; |
| | | onePortMqttFR.DHCP = usefullBytes [51] == 0 ? false : true; |
| | | if (usefullBytes.Length == 97) { |
| | | onePortMqttFR.AESEnable = usefullBytes [53] == 0 ? false : true; |
| | | onePortMqttFR.AESPassword = MyEncodingGB2312.GetString (usefullBytes, 54, 16).Trim ('\0'); |
| | | onePortMqttFR.DNSEnable = usefullBytes [70] == 0 ? false : true; |
| | | onePortMqttFR.DNSAddress = usefullBytes [71] + "." + usefullBytes [72] + "." + usefullBytes [73] + "." + usefullBytes [74]; |
| | | onePortMqttFR.DNSAlternateAddress = usefullBytes [75] + "." + usefullBytes [76] + "." + usefullBytes [77] + "." + usefullBytes [78]; |
| | | onePortMqttFR.WirelessBand = usefullBytes [79]; |
| | | onePortMqttFR.WirelessChannel = usefullBytes [80]; |
| | | onePortMqttFR.WirelessPassword = MyEncodingGB2312.GetString (usefullBytes, 81, 16).Trim ('\0'); |
| | | } |
| | | GateWayList.Add (onePortMqttFR); |
| | | if (onePortMqttFR.Name == "") { |
| | | onePortMqttFR.Name = onePortMqttFR.CommonLoopID.ToString (); |
| | | } |
| | | Application.RunOnMainThread (() => { |
| | | GuideAddGateway.InitGatewayRowView (onePortMqttFR); |
| | | }); |
| | | //IO.FileUtils.SaveEquipmentMessage (onePortWirelessFR); |
| | | //System.Threading.Tasks.Task.Run (() => { |
| | | // if (string.IsNullOrEmpty (UserConfig.Current.RemoteModeFile)) { |
| | | // var gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, onePortWirelessFR.SubnetID, onePortWirelessFR.DeviceID, new byte [] { }); |
| | | // if (gatewayBytes!=null&&gatewayBytes [0] == 2) { |
| | | // UserConfig.Current.RemoteModeFile = "Equipment_" + onePortWirelessFR.Type.ToString () + "_" + onePortWirelessFR.SubnetID.ToString () + "_" + onePortWirelessFR.DeviceID.ToString (); |
| | | // UserConfig.Current.SaveUserConfig (); |
| | | // } |
| | | // } |
| | | //}); |
| | | #endregion |
| | | |
| | | break; |
| | | case DeviceType.OnePortWirelessFR: |
| | | |
| | | #region |
| | | OnePortWirelessFR onePortWirelessFR = new OnePortWirelessFR (); |
| | | string wirelessPath = "Equipment_" + typeof (OnePortWirelessFR).Name + "_" + subnetID + "_" + deviceID; |
| | |
| | | continue; |
| | | } |
| | | deviceType = (DeviceType)(usefullBytes [iReadDeviceModulACK] * 256 + usefullBytes [iReadDeviceModulACK + 1]); |
| | | Console.WriteLine (deviceType.ToString ()); |
| | | Utlis.WriteLine (deviceType.ToString ()); |
| | | string devcieTempName = MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0'); |
| | | if (notHasRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") { |
| | | devcieTempName = deviceType.ToString ().Replace (DeviceType.Sensor.ToString (), "") + "-" + deviceID.ToString (); |
| | |
| | | wirelessPanelButtonKey.Name = MyEncodingGB2312.GetString (usefullBytes, 3, 20).Trim ('\0'); |
| | | wirelessPanelButtonKey.Mode = usefullBytes [23]; |
| | | ButtonBkeyModelList.Add (wirelessPanelButtonKey.Mode); |
| | | System.Console.WriteLine ("读取面板按键:回路号:" + wirelessPanelButtonKey.LoopID + " 模式:" + wirelessPanelButtonKey.Mode); |
| | | Utlis.WriteLine ("读取面板按键:回路号:" + wirelessPanelButtonKey.LoopID + " 模式:" + wirelessPanelButtonKey.Mode); |
| | | IO.FileUtils.SaveEquipmentMessage (wirelessPanelButtonKey, wirelessPanelButtonKey.LoopID.ToString ()); |
| | | #endregion |
| | | break; |
| | |
| | | //01 01 59(+30) 02 0D 03 64 00 01 |
| | | break; |
| | | case Command.AssignedAddressACK: |
| | | Console.WriteLine (usefullBytes [0].ToString ()); |
| | | Utlis.WriteLine (usefullBytes [0].ToString ()); |
| | | if (usefullBytes [0] == 3) { |
| | | dt = DateTime.Now; |
| | | } else if (usefullBytes [0] == 4) { |
| | |
| | | } |
| | | break; |
| | | case Command.Remote3thACK: |
| | | Console.WriteLine (usefullBytes [0]); |
| | | Utlis.WriteLine (usefullBytes [0]); |
| | | break; |
| | | case Command.DownloadInfraredACK: |
| | | string loopID_IM = usefullBytes [0] < 10 ? "0" + usefullBytes [0].ToString () : usefullBytes [0].ToString (); |
| | | if ((InfraredType)usefullBytes [2] != InfraredType.AC) { |
| | | if ((InfraredType)usefullBytes [2] == InfraredType.NULL) { |
| | | Console.WriteLine ("NULL-------------"); |
| | | Utlis.WriteLine ("NULL-------------"); |
| | | } |
| | | string filePath = "Equipment_InfraredMode_" + subnetID + "_" + deviceID + "_" + loopID_IM; |
| | | InfraredMode im = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (filePath))); |
| | | im.InfraredType = (InfraredType)usefullBytes [2]; |
| | | Console.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------"); |
| | | Utlis.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------"); |
| | | IO.FileUtils.SaveEquipmentMessage (im, im.LoopID.ToString ()); |
| | | } |
| | | break; |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine ("Packet_ReceiveEvent:" + ex.ToString ()); |
| | | Utlis.WriteLine ("Packet_ReceiveEvent:" + ex.ToString ()); |
| | | } |
| | | |
| | | } |
| | |
| | | outputStream.Flush (); |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine ("httpListener_EventHandler" + ex.ToString ()); |
| | | Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ()); |
| | | } |
| | | } |
| | | |