Connecting to the Device
Connecting to a Bluetooth Smart device also looks the same as connecting to a Bluetooth RFCOMM device:
async Task<GattDeviceService> GetBloodPressureServiceAsync() { foreach (DeviceInformation deviceInfo in await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid( GattServiceUuids .BloodPressure))) { // Return the first one (null if user doesn't consent) // Be sure to call FromIdAsync on the UI thread! return await GattDeviceService.FromIdAsync(deviceInfo.Id); } return null; }
One difference is that GattDeviceService
forces you to specify a service ID when getting a device selector, either via GetDeviceSelectorFromUuid ...
Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.