Tech Off Post

Single Post Permalink

View Thread: Using bluetooth on a Universal Windows app for Lumia 950XL
  • User profile image
    Tokter

    I'm trying to write an app for my phone that connects to a BLE device.

    The device is paired and I edited the appxmanifest to enable the bluetooth capabilities.

    But when I run the code below,

    await BluetoothLEDevice.FromIdAsync(deviceInfo.Id);

    results in an Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.ni.dll

    Does anyone have an idea what I'm doing wrong?

    Thanks!

                var deviceList = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.GenericAccess), null);
                int count = deviceList.Count();
                if (count > 0)
                {
                    var deviceInfo = deviceList.Where(x => x.Name == "XC-Tracer").FirstOrDefault();
                    if (deviceInfo != null)
                    {
                        if (deviceInfo.IsEnabled)
                        {
                            var bleDevice = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id);
                            var deviceServices = bleDevice.GattServices;
                        }
                    }
                }