public void SendCommand(SkyCommands code) { var commandBytes = new byte[] { 4, 1, 0, 0, 0, 0, (byte)Math.Floor(224 + ((int)code / 16d)), (byte)((int)code % 16) }; var commandBytes2 = new byte[] { 4, 0, 0, 0, 0, 0, (byte)Math.Floor(224 + ((int)code / 16d)), (byte)((int)code % 16) }; using (TcpClient client = new TcpClient(Host, Port)) using (NetworkStream ns = client.GetStream()) { ns.WriteTimeout = ConnectTimeout; ns.ReadTimeout = ConnectTimeout; try { byte[] handShake = new byte[24]; ns.Read(handShake, 0, 12); ns.Write(handShake, 0, 12); ns.Read(handShake, 0, 2); ns.Write(handShake, 0, 1); ns.Read(handShake, 0, 4); ns.Write(handShake, 0, 1); ns.Read(handShake, 0, 24); ns.Write(commandBytes, 0, commandBytes.Length); ns.Write(commandBytes2, 0, commandBytes2.Length); } catch (Exception e) { Console.WriteLine(e); } } }
public static bool GoToChannel(string ip, SkyCommands n1, SkyCommands n2, SkyCommands n3) { try { SkyRemote remote = new SkyRemote(ip, SkyRemote.SKY_Q); remote.Press(n1); Thread.Sleep(50); remote.Press(n2); Thread.Sleep(50); remote.Press(n3); return(true); } catch (Exception) { return(false); } }
public void Press(SkyCommands button) { SendCommand(button); }