LAK132

Untitled

Jun 1st, 2016
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1.         public async void StartScanningForDevices(params string[] serviceUuids)
  2.         {
  3.             DiscoveredDevices = new List<IDevice>();
  4.             IsScanning = true;
  5.             List<DeviceInformationCollection> col = new List<DeviceInformationCollection>();
  6.  
  7.             if (serviceUuids.Length < 1)
  8.             {
  9.                 col.Add(await DeviceInformation.FindAllAsync());
  10.             }
  11.             else
  12.             {
  13.                 foreach (var id in serviceUuids)
  14.                 {
  15.                     col.Add(await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(id.ToGuid())));
  16.                 }
  17.             }
  18.  
  19.             for (int i = 0; i < col.ToArray().Length; i++)
  20.             {
  21.                 foreach (DeviceInformation x in col[i].ToList())
  22.                 {
  23.                     Device device = null;
  24.                     try
  25.                     {
  26.                         device = new Device(await Device.DeviceFromDeviceInfo(x));
  27.                         DiscoveredDevices.Add(device);
  28.                         DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device));
  29.                     }
  30.                     catch (Exception e)
  31.                     {
  32.                         //throw new Exception(message:e.Message);
  33.                     }
  34.                 }
  35.             }
  36.             IsScanning = false;
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment