protected void OnDeviceFound(DeviceFoundEventArgs e) { if (DeviceFound != null) { DeviceFound(this, e); } }
private void ClientOnDeviceFound(object sender, DeviceFoundEventArgs deviceFoundEventArgs) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate { DeviceList.Text += deviceFoundEventArgs.Device.DeviceType.friendlyName + Environment.NewLine; }); }
void transport_NewDeviceFound(object sender, DeviceFoundEventArgs e) { if (InvokeRequired) { BeginInvoke(new EventHandler <DeviceFoundEventArgs>(transport_NewDeviceFound), sender, e); return; } AddDevice(e.Id, e.IpAddress); }
private void OnDeviceFound(object sender, DeviceFoundEventArgs e) { var status = e.Device.Connect(); if (!status.Result) { Debug.WriteLine("Failed to connect to Yeelight Device."); return; } _connectedDevices.Add(e.Device); }
private static async Task adapter_DeviceFoundAsync(Adapter adapter, DeviceFoundEventArgs e) { try { var device = e.Device; var deviceDescription = await GetDeviceDescriptionAsync(device); if (e.IsStateChange) { Console.WriteLine($"Found: [NEW] {deviceDescription}"); } else { Console.WriteLine($"Found: {deviceDescription}"); } var deviceAddress = await device.GetAddressAsync(); var deviceName = await device.GetAliasAsync(); if (deviceAddress.Equals(s_deviceFilter, StringComparison.OrdinalIgnoreCase) || deviceName.Contains(s_deviceFilter, StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Stopping scan...."); try { await adapter.StopDiscoveryAsync(); Console.WriteLine("Stopped."); } catch (Exception ex) { // Best effort. Sometimes BlueZ gets in a state where you can't stop the scan. Console.Error.WriteLine($"Error stopping scan: {ex.Message}"); } device.Connected += device_ConnectedAsync; device.Disconnected += device_DisconnectedAsync; device.ServicesResolved += device_ServicesResolvedAsync; Console.WriteLine($"Connecting to {await device.GetAddressAsync()}..."); await device.ConnectAsync(); } } catch (Exception ex) { Console.Error.WriteLine(ex); } }
static async Task OnDeviceFoundAsync(Adapter sender, DeviceFoundEventArgs eventArgs) { var device = eventArgs.Device; var properties = await device.GetAllAsync(); foreach (var uuid in properties.UUIDs) { if (string.Equals(uuid, COVIDSAFE_SERVICE_UUID, StringComparison.OrdinalIgnoreCase)) { await OnCovidSafeUserFoundAsync(device); return; } } }
void Disco_DeviceFound(object sender, DeviceFoundEventArgs e) { string location = string.Empty; string service = string.Empty; if (!e.Results.TryGetValue("SERVICE", out service)) return; if (service.StartsWith("com.marvell.wm") && e.Results.TryGetValue("LOCATION", out location)) { var newTstat = new ThermostatBase(location); var existingTstat = Results.Where(t => t.Equals(newTstat)).SingleOrDefault(); if (existingTstat == null) Results.Add(newTstat); } }
private void SSDP_DeviceFound(object sender, DeviceFoundEventArgs e) { string location = string.Empty; string service = string.Empty; if (!e.Results.TryGetValue("SERVICE", out service)) { return; } if (service.StartsWith("com.marvell.wm") && e.Results.TryGetValue("LOCATION", out location)) { location = location.Replace("http://", "").Replace("/sys/", ""); Platform.Current.Logger.Log(LogLevels.Warning, "SearchThermostats_Found {0}", location); Platform.Current.Analytics.Event("SearchThermostats_Found", location); this.InvokeOnUIThread(async() => { try { ThermostatViewModel vm = Platform.Current.ViewModel.Thermostats.FirstOrDefault(f => f.IPAddress == location); if (vm == null) { vm = this.CreateThermostatViewModel(location); _devicesAdded++; await vm.RefreshAsync(true); Platform.Current.Logger.Log(LogLevels.Warning, "SearchThermostats_Added {0}", location); Platform.Current.Analytics.Event("SearchThermostats_Added", location); } else { Platform.Current.Logger.Log(LogLevels.Warning, "SearchThermostats_AlreadyExists {0}", location); Platform.Current.Analytics.Event("SearchThermostats_AlreadyExists", location); } if (_devicesAdded > 0) { this.SearchStatus = $"Searching...devices found: {_devicesAdded}"; } } catch (Exception ex) { await this.HandleExceptionAsync(ex, $"Error while trying to add new thermostat at {location}"); } }); } }
/// <summary> /// Runs the ping. /// </summary> public void RunPing() { //nFound = 0; List <Task <PingReply> > tasks = new List <Task <PingReply> >(); stopWatch.Start(); foreach (var ip in ipAddresses) { tasks.Add(PingAndUpdateAsync(new Ping(), ip)); } Task.WaitAll(tasks.ToArray()); var reachable = tasks.Where(x => x.Result?.Status == IPStatus.Success).ToList(); var cnt = 1; foreach (var result in reachable) { var reply = result.Result; var fd = new FoundDevice { IpAddress = reply.Address.ToString(), DeviceId = Utils.Common, DeviceName = Utils.Common, Id = cnt, FoundAt = DateTime.Now, FoundUsing = "Ping" }; var args = new DeviceFoundEventArgs { Found = cnt, TimeReached = DateTime.Now, Item = fd }; OnDeviceReached(args); cnt++; } }
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)); }); } } }
protected void OnDeviceReached(DeviceFoundEventArgs e) => EventHostFound?.Invoke(this, e);
private static void DeviceFoundHandler(object sender, DeviceFoundEventArgs args) { Console.WriteLine($"Found device: {args.Usn}, {args.DescriptionLocation}"); }