LAK132 icon

Untitled

LAK132 | PRO | 06/02/16 04:16:59 AM UTC | 0 ⭐ | 435 👁️ | Never ⏰ | []
C# |

1.37 KB

|

None

|

0 👍

/

0 👎

        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;
        }

Comments