Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async void StartScanningForDevices(params string[] serviceUuids)
- {
- DiscoveredDevices = new List<IDevice>();
- IsScanning = true;
- List<DeviceInformationCollection> col = new List<DeviceInformationCollection>();
- if (serviceUuids.Length < 1)
- {
- col.Add(await DeviceInformation.FindAllAsync());
- }
- else
- {
- foreach (var id in serviceUuids)
- {
- col.Add(await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(id.ToGuid())));
- }
- }
- for (int i = 0; i < col.ToArray().Length; i++)
- {
- foreach (DeviceInformation x in col[i].ToList())
- {
- Device device = null;
- try
- {
- device = new Device(await Device.DeviceFromDeviceInfo(x));
- DiscoveredDevices.Add(device);
- DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device));
- }
- catch (Exception e)
- {
- //throw new Exception(message:e.Message);
- }
- }
- }
- IsScanning = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment