public static LifxRequest Create(ILifxHub hub, LifxPacket packet) { switch (packet.Info.PacketType) { case LifxPacketType.GetStateService: return new LifxServiceStateRequest(packet); case LifxPacketType.GetWiFiFirmwareState: return new LifxWiFiFirmwareRequest(packet); case LifxPacketType.GetMeshFirmwareState: return new LifxMeshFirmwareRequest(packet); case LifxPacketType.GetVersion: return new LifxVersionRequest(packet); case LifxPacketType.GetLightState: return new LifxLightStateRequest(packet); case LifxPacketType.SetLightState: return new LifxLightStateRequest(packet); default: return null; // throw new ArgumentOutOfRangeException("Protocol"); } }
public static LifxPacket Parse(byte[] data) { var result = new LifxPacket(); if (result.TryParse(data)) { return result; } return null; }
protected LifxRequest(LifxPacket packet) { this.Packet = packet; }
public LifxPowerStateRequest(LifxPacket packet) : base(packet) { this.power = BitHelper.ReadUInt16(this.Packet.Payload, 0); }
public LifxMeshFirmwareRequest(LifxPacket packet) : base(packet) { }
public LifxLightStateRequest(LifxPacket packet) : base(packet) { this.color = LifxHsbkColor.FromBytes(this.Packet.Payload, 1); this.Duration = BitHelper.ReadUInt16(this.Packet.Payload, 1 + LifxHsbkColor.Size); }
public LifxVersionRequest(LifxPacket packet) : base(packet) { }
public LifxServiceStateRequest(LifxPacket packet) : base(packet) { }