static Task <IReadOnlyCollection <BluetoothDevice> > PlatformGetPairedDevices() { #if __IOS__ PairedDeviceHandler deviceHandler = new PairedDeviceHandler(); OnRetrievedPeripherals += deviceHandler.OnRetrievedPeripherals; _manager.RetrieveConnectedPeripherals(CBUUID.FromPartial(0x180F)); return(Task.Run(() => { //deviceHandler.WaitOne(); return deviceHandler.Devices; })); #else return(Task.FromResult((IReadOnlyCollection <BluetoothDevice>) new List <BluetoothDevice>().AsReadOnly())); #endif }
static Task <IReadOnlyCollection <BluetoothDevice> > PlatformGetPairedDevices() { #if __IOS__ PairedDeviceHandler deviceHandler = new PairedDeviceHandler(); OnRetrievedPeripherals += deviceHandler.OnRetrievedPeripherals; List <BluetoothDevice> devices = new List <BluetoothDevice>(); var periphs = _manager.RetrieveConnectedPeripherals(GattServiceUuids.GenericAccess, GattServiceUuids.GenericAttribute, GattServiceUuids.DeviceInformation, GattServiceUuids.Battery); foreach (var p in periphs) { devices.Add(p); } return(Task.Run(() => { return (IReadOnlyCollection <BluetoothDevice>)devices.AsReadOnly(); })); #else return(Task.FromResult((IReadOnlyCollection <BluetoothDevice>) new List <BluetoothDevice>().AsReadOnly())); #endif }
static Task <IReadOnlyCollection <BluetoothDevice> > PlatformGetPairedDevices() { #if __IOS__ PairedDeviceHandler deviceHandler = new PairedDeviceHandler(); OnRetrievedPeripherals += deviceHandler.OnRetrievedPeripherals; List <BluetoothDevice> devices = new List <BluetoothDevice>(); var periphs = _manager.RetrieveConnectedPeripherals(CBUUID.FromPartial(0x1801)); foreach (var p in periphs) { devices.Add(p); } return(Task.Run(() => { return (IReadOnlyCollection <BluetoothDevice>)devices.AsReadOnly(); })); #else return(Task.FromResult((IReadOnlyCollection <BluetoothDevice>) new List <BluetoothDevice>().AsReadOnly())); #endif }