public async void Search()
        {
            if (firstAdapter == null)
                return;

            await firstAdapter.ScanAsync();

            //firstAdapter.AvailableNetworksChanged += FirstAdapter_AvailableNetworksChanged;

            var qualifyingWifi = firstAdapter.NetworkReport.AvailableNetworks.Where(N => N.Ssid.ToLower().StartsWith("ioespt-thing"));

            foreach (WiFiAvailableNetwork deviceWifi in qualifyingWifi)
            {
                RegisteredDevice FoundDevice = new RegisteredDevice()
                {
                    Status = DeviceStatus.UnProvisioned,
                    ConnectedTo = "None",
                    GivenName = deviceWifi.Ssid,
                    ChipId = "Unknown",
                    FirmwareName = "Unknown",
                    FirmwareVersion = "Unknown",
                    ModuleType = "Unknown"
                };

                if (DeviceFound != null)
                    DeviceFound(this, new DeviceFoundEventArgs(FoundDevice));
            }
        }
 public void DeleteDevice(RegisteredDevice device)
 {
     db.Table<RegisteredDevice>().Delete( C=> C.ChipId == device.ChipId);
 }
 public void InsertNewDevice(RegisteredDevice device)
 {
     db.Insert(device);
 }
        private async void SsdpClient_DeviceFound(object sender, DeviceFoundEventArgs e)
        {
            if (e.Device.DeviceType.manufacturer == "IOESPT")
            {
                var foundDevice = devices.FirstOrDefault(D => D.DeviceDetails.ChipId == e.Device.DeviceType.serialNumber);

                Uri uri = new Uri(e.Device.URLBase);


                if (foundDevice != null)
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => {
                        foundDevice.DeviceDetails.Status = DeviceStatus.Online;

                        foundDevice.DeviceDetails.Ip = uri.Host;
                    });
                }
                else
                {
                    //We have a new device online
                    var newDevice = new RegisteredDevice();

                    newDevice.ChipId = e.Device.DeviceType.serialNumber;
                    newDevice.FirmwareName = e.Device.DeviceType.modelName;
                    newDevice.ModuleType = e.Device.DeviceType.modelName;
                    newDevice.FirmwareVersion = e.Device.DeviceType.modelNumber;
                    newDevice.GivenName = e.Device.DeviceType.friendlyName;
                    newDevice.Status = DeviceStatus.Online;
                    newDevice.ConnectedTo = "None";
                    newDevice.Ip = uri.Host;

                    db.InsertNewDevice(newDevice);

                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => {
                        devices.Add(DeviceTypeFactory.MakeDevice(newDevice.FirmwareName, newDevice));
                    });


                }
            }
        }
 public DeviceFoundEventArgs(RegisteredDevice device)
 {
     Device = device;
 }