Ejemplo n.º 1
0
        private bool InternalSendCommand(String command)
        {
            if (UDAPnP.Protocol == UDAPnP.LGProtocol.LG2011 ||
                UDAPnP.Protocol == UDAPnP.LGProtocol.LG2012x)
            {
                if (!UDAPnP.HandleKeyInput(command))
                {
                    // if for some reason connection was lost, try to reconnect

                    if (!ConnectAndPair())
                    {
                        Auto3DHelpers.ShowAuto3DMessage("Connection to LG TV failed!", false, 0);
                        Log.Error("Auto3D: Connection to LG TV failed!");

                        return(false);
                    }

                    // second try to send the command

                    if (!UDAPnP.HandleKeyInput(command))
                    {
                        Log.Error("Auto3D: HandleKeyInput failed for command: " + command);
                        return(false);
                    }
                }
            }
            else // WebOS
            {
                WebOS.SendSpecialKey(command);
            }

            return(true);
        }
Ejemplo n.º 2
0
        internal bool ConnectAndPair()
        {
            if (UDAPnP.Protocol == UDAPnP.LGProtocol.LG2011 ||
                UDAPnP.Protocol == UDAPnP.LGProtocol.LG2012x)
            {
                // LG UPnP stack is sometimes very slow in answering,
                // so wait up to 5 seconds before giving up pairing.

                int loops = 0;

                while (IPAddress == null || IPAddress.Length == 0)
                {
                    Thread.Sleep(5);

                    if (loops++ > 100)
                    {
                        Log.Error("Auto3D: LG service not connected withing additional 10 seconds!");
                        return(false);
                    }
                }

                if (UDAPnP.UpdateServiceInformation(IPAddress))
                {
                    Log.Info("Auto3D: UpdateServiceInfo OK");

                    if (PairingKey.Length > 0)
                    {
                        if (UDAPnP.RequestPairing(PairingKey))
                        {
                            Log.Info("Auto3D: Pairing LG client with key {0} succeeded", PairingKey);
                        }
                        else
                        {
                            Log.Error("Auto3D: Pairing LG client with key {0} failed!", PairingKey);
                            return(false);
                        }
                    }
                }
                else
                {
                    Log.Error("Auto3D: UpdateServiceInfo failed!");
                    return(false);
                }
            }
            else // WebOS
            {
                WebOS.Register(IPAddress, PairingKey);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void buttonSendKey_Click(object sender, EventArgs e)
        {
            if (!UDAPnP.Connected)
            {
                if (!UDAPnP.UpdateServiceInformation(_device.IPAddress))
                {
                    MessageBox.Show("Connection to LG TV failed!");
                    return;
                }
            }

            if (UDAPnP.RequestPairing(textBoxPairingKey.Text))
            {
                SaveSettings();
            }
        }
Ejemplo n.º 4
0
        private void buttonShowKey_Click(object sender, EventArgs e)
        {
            if (UDAPnP.Protocol == UDAPnP.LGProtocol.LG2011 ||
                UDAPnP.Protocol == UDAPnP.LGProtocol.LG2012x)
            {
                if (!UDAPnP.Connected)
                {
                    if (!UDAPnP.UpdateServiceInformation(_device.IPAddress))
                    {
                        MessageBox.Show("Connection to LG TV failed!");
                        return;
                    }
                }

                UDAPnP.RequestPairingKey();
            }
            else // WebOS
            {
                textBoxPairingKey.Text = WebOS.Pair(_device.IPAddress);
                SaveSettings();
            }
        }