Пример #1
0
        public async Task <List <BaseDevice> > FindDevices()
        {
            _searching = true;
            Devices    = new List <BaseDevice>();
            var msg = new byte[] { 0xFC, 0x05, 0xFF, 0x30, 0x01, 0x0A, 0x2A };

            DreamSender.SendUdpBroadcast(msg);
            var s = new Stopwatch();

            s.Start();
            await Task.Delay(3000).ConfigureAwait(true);

            Devices = Devices.Distinct().ToList();
            s.Stop();
            _searching = false;
            DreamData.SetItem("devices", Devices);
            return(Devices);
        }
Пример #2
0
        public static async Task <List <BaseDevice> > Discover()
        {
            LogUtil.Write("Discovery started..");
            // Send a custom internal message to self to store discovery results
            var selfEp = new IPEndPoint(IPAddress.Loopback, 8888);

            DreamSender.SendUdpWrite(0x01, 0x0D, new byte[] { 0x01 }, 0x30, 0x00, selfEp);
            // Send our notification to actually discover
            var msg = new byte[] { 0xFC, 0x05, 0xFF, 0x30, 0x01, 0x0A, 0x2A };

            DreamSender.SendUdpBroadcast(msg);
            await Task.Delay(3000).ConfigureAwait(false);

            DreamSender.SendUdpWrite(0x01, 0x0E, new byte[] { 0x01 }, 0x30, 0x00, selfEp);
            await Task.Delay(500).ConfigureAwait(false);

            var devices = DataUtil.GetDreamDevices();

            return(devices);
        }