Ejemplo n.º 1
0
        public Boxes(Helper aHelper, EventServerUpnp aEventServer, ISsdpNotifyProvider aSsdpNotify, bool aDiscoverProxyDevices)
        {
            iLock           = new object();
            iHelper         = aHelper;
            iEventServer    = aEventServer;
            iListenerNotify = aSsdpNotify;
            iTree           = new Tree(aHelper);

            //listen to the volkano service
            iDeviceListVolkano = new DeviceListUpnp(ServiceVolkano.ServiceType(), iListenerNotify);
            iDeviceListVolkano.EventDeviceAdded   += VolkanoAddedHandler;
            iDeviceListVolkano.EventDeviceRemoved += VolkanoRemovedHandler;

            //listen to the proxy service
            if (aDiscoverProxyDevices)
            {
                iDeviceListProxy = new DeviceListUpnp(ServiceProxy.ServiceType(), iListenerNotify);
                iDeviceListProxy.EventDeviceAdded   += ProxyAddedHandler;
                iDeviceListProxy.EventDeviceRemoved += ProxyRemovedHandler;
            }

            // Configure Service Point Manager
            ServicePointManager.DefaultConnectionLimit = 50;
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;
        }
Ejemplo n.º 2
0
        internal Item(Helper aHelper, Tree aTree, Device aDevice, EventServerUpnp aEventServer, bool aIsProxy)
        {
            iLock        = new object();
            iHelper      = aHelper;
            iTree        = aTree;
            iEventServer = aEventServer;
            iIsProxy     = aIsProxy;
            iBasicSetup  = new BasicSetup(aDevice, aEventServer);
            iPlayback    = new Playback(aHelper, aDevice, aEventServer);

            if (aIsProxy)
            {
                iServiceProxy = new ServiceProxy(aDevice);
            }
            else
            {
                iServiceVolkano = new ServiceVolkano(aDevice);
            }

            if (Box.IsFallBack(aDevice.Udn) && !aIsProxy)
            {
                iBox = iTree.AddFallbackBox(iBasicSetup, aDevice, aEventServer, iProductId, iBoardId.ToArray(), iBoardType.ToArray(), iBoardDescription.ToArray(), iBoardNumber.ToArray(), iSoftwareVersion);
                GetVersionInfo();
            }
            else
            {
                //wait for service product to collect box data before turning on Box
                iServiceProduct = new ServiceProduct(aDevice, iEventServer);
                iServiceProduct.EventInitial += EventHandlerProductInitial;
            }
        }
Ejemplo n.º 3
0
        public bool IssueReboot()
        {
            iConsole.Write("Rebooting .......................... ");

            ServiceVolkano volkano = new ServiceVolkano(iDevice);

            ServiceVolkano.AsyncActionReboot async = volkano.CreateAsyncActionReboot();

            async.EventResponse += RebootResponse;

            iIsRebootAccepted.Reset();
            iIsByeByeReceived.Reset();
            iIsAliveReceived.Reset();

            iMutex.WaitOne();

            iNotifyByeByeReceived = false;

            iMutex.ReleaseMutex();

            iDeviceUdnPrefix = iDevice.Udn.Substring(0, 32);

            async.RebootBegin();

            return(WaitFor(iIsRebootAccepted, kMaxRebootAcceptedSeconds));
        }
Ejemplo n.º 4
0
        private void DeviceAdded(object obj, DeviceList.EventArgsDevice e)
        {
            ServiceVolkano volkano = new ServiceVolkano(e.Device);

            ServiceVolkano.AsyncActionUglyName async = volkano.CreateAsyncActionUglyName();

            async.EventResponse += UglyNameResponse;

            async.UglyNameBegin();
        }
Ejemplo n.º 5
0
        internal void Open(Device aDevice)
        {
            lock (iLock)
            {
                // close previous services cleanly
                if (iIsProxy)
                {
                    iServiceProxy = new ServiceProxy(aDevice);
                }
                else
                {
                    iServiceVolkano = new ServiceVolkano(aDevice);
                }

                iBasicSetup = new BasicSetup(aDevice, iEventServer);
                iPlayback   = new Playback(iHelper, aDevice, iEventServer);

                if (Box.IsFallBack(aDevice.Udn) && !iIsProxy)
                {
                    //if device in fallback state create a box not containing the service product
                    if (iBox != null)
                    {
                        iBox.SetFallback(aDevice);
                    }
                    else
                    {
                        iBox = iTree.AddFallbackBox(iBasicSetup, aDevice, iEventServer, iProductId, iBoardId.ToArray(), iBoardType.ToArray(), iBoardDescription.ToArray(), iBoardNumber.ToArray(), iSoftwareVersion);
                    }
                    GetVersionInfo();
                }
                else
                {
                    if (iServiceProduct != null)
                    {
                        if (!iEventInitialOn)
                        {
                            iServiceProduct.EventInitial -= EventHandlerProductInitial;
                        }
                        else
                        {
                            iServiceProduct.EventInitial -= EventHandlerProductInitialOn;
                        }
                        iServiceProduct.Kill();
                        iServiceProduct = null;
                    }
                    //wait for service product to collect box data before turning on Box
                    iServiceProduct = new ServiceProduct(aDevice, iEventServer);
                    iServiceProduct.EventInitial += EventHandlerProductInitialOn;
                    iEventInitialOn = true;
                }
            }
        }
Ejemplo n.º 6
0
        private void DeviceAdded(object obj, DeviceList.EventArgsDevice e)
        {
            if (!iFound)
            {
                Trace.WriteLine(Trace.kTopology, "Added: " + e.Device.Udn);

                ServiceVolkano volkano = new ServiceVolkano(e.Device);

                ServiceVolkano.AsyncActionUglyName async = volkano.CreateAsyncActionUglyName();

                async.EventResponse += UglyNameResponse;

                async.UglyNameBegin();
            }
        }
Ejemplo n.º 7
0
        public bool SetBootMode(string aMode)
        {
            iConsole.Write("Setting boot mode .................. ");

            ServiceVolkano volkano = new ServiceVolkano(iDevice);

            ServiceVolkano.AsyncActionSetBootMode async = volkano.CreateAsyncActionSetBootMode();

            async.EventResponse += SetBootModeResponse;

            iIsBootModeSet.Reset();

            async.SetBootModeBegin(aMode);

            return(WaitFor(iIsBootModeSet, kMaxSetBootModeSeconds));
        }
Ejemplo n.º 8
0
        public DeviceFinder(string aUglyName)
        {
            iUglyName = aUglyName;

            ServiceType type = ServiceVolkano.ServiceType();

            type.Version = 1;

            iListener = new SsdpListenerMulticast();

            iDeviceList = new DeviceListUpnp(type, iListener);

            iDeviceList.EventDeviceAdded += DeviceAdded;

            iSemaphore = new ManualResetEvent(false);

            iFound = false;
        }
Ejemplo n.º 9
0
        internal BasicSetup(Device aDevice, EventServerUpnp aEventServer)
        {
            iLock = new object();
            if (aDevice.HasService(ServiceConfiguration.ServiceType(1)) > 0)
            {
                iServiceConfiguration = new ServiceConfiguration(aDevice, aEventServer);
                iServiceConfiguration.EventInitial += EventHandlerConfigurationInitial;
                iActionSetParameter             = iServiceConfiguration.CreateAsyncActionSetParameter();
                iActionSetParameter.EventError += SetParameterError;
            }

            if (aDevice.HasService(ServiceVolkano.ServiceType(1)) > 0)
            {
                iServiceVolkano = new ServiceVolkano(aDevice);
                iActionReboot   = iServiceVolkano.CreateAsyncActionReboot();
            }
            iDeviceIpAddress = aDevice.IpAddress;
        }
Ejemplo n.º 10
0
        public bool FindDevice()
        {
            iIsFound.Reset();

            iDeviceList = new DeviceListUpnp(ServiceVolkano.ServiceType(), iListener);

            iDeviceList.EventDeviceAdded += DeviceAdded;

            iDeviceList.Start(iInterface);

            bool result = false;

            uint i = kMaxFindRetries;

            while (i-- > 0)
            {
                iConsole.Write("Finding " + iUglyName + " ................ ");

                if (WaitFor(iIsFound, kMaxFindSeconds))
                {
                    result = true;
                    break;
                }

                if (i > 0)
                {
                    iConsole.Write("Retry");
                    iConsole.Newline();
                    iDeviceList.Rescan();
                }
            }

            iDeviceList.EventDeviceAdded -= DeviceAdded;
            iDeviceList.Stop();

            return(result);
        }