public override void DiscoverServices() { Windows.Foundation.IAsyncOperation <Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult> task = nativeDevice.GetGattServicesAsync(BluetoothCacheMode.Uncached); while (task.Status == Windows.Foundation.AsyncStatus.Started) { Thread.Sleep(50); } Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult result = task.GetResults(); this._services.Clear(); if (result.Status == Windows.Devices.Bluetooth.GenericAttributeProfile.GattCommunicationStatus.Success) { foreach (var item in result.Services) { Debug.WriteLine("Device.Discovered Service: " + item.DeviceId); this._services.Add(new Service(item)); } ServicesDiscovered?.Invoke(this, new EventArgs()); } else { } }
async Task <List <GattService> > PlatformGetPrimaryServices(BluetoothUuid?service) { var services = new List <GattService>(); Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult result = null; if (service == null) { result = await Device.NativeDevice.GetGattServicesAsync(Windows.Devices.Bluetooth.BluetoothCacheMode.Uncached); } else { result = await Device.NativeDevice.GetGattServicesForUuidAsync(service.Value, Windows.Devices.Bluetooth.BluetoothCacheMode.Uncached); } if (result != null && result.Services.Count > 0) { foreach (var serv in result.Services) { services.Add(new GattService(Device, serv)); } } return(services); }
async Task <List <BluetoothRemoteGATTService> > DoGetPrimaryServices(Guid?service) { var services = new List <BluetoothRemoteGATTService>(); Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult result = null; if (service == null) { result = await Device.NativeDevice.GetGattServicesAsync(); } else { result = await Device.NativeDevice.GetGattServicesForUuidAsync(service.Value); } if (result != null || result.Services.Count > 0) { foreach (var serv in result.Services) { services.Add(new BluetoothRemoteGATTService(Device, serv)); } } return(services); }
async Task <GattService> PlatformGetPrimaryService(BluetoothUuid service) { Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult result = null; result = await Device.NativeDevice.GetGattServicesForUuidAsync(service, Windows.Devices.Bluetooth.BluetoothCacheMode.Uncached); if (result == null || result.Services.Count == 0) { return(null); } return(new GattService(Device, result.Services[0])); }
async Task <BluetoothRemoteGATTService> DoGetPrimaryService(Guid?service) { Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult result = null; if (service.HasValue) { result = await Device.NativeDevice.GetGattServicesForUuidAsync(service.Value); } else { result = await Device.NativeDevice.GetGattServicesAsync(); } if (result == null || result.Services.Count == 0) { return(null); } return(new BluetoothRemoteGATTService(Device, result.Services[0])); }