3
votes
  1. I have a code to list all the BluetoothLE devices a Windows Phone 8.1 can detects (paired and unpaired):

        var devices = await DeviceInformation.FindAllAsync( BluetoothLEDevice.GetDeviceSelector() );
        foreach ( DeviceInformation di in devices )
            {
            BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync( di.Id );
    
            Debug.WriteLine( bleDevice.Name );
            }
    

However, the line:

var devices = await DeviceInformation.FindAllAsync( BluetoothLEDevice.GetDeviceSelector() );

Throws an exception.

Any Idea why?

  1. I also tried this code:

    var devices = await DeviceInformation.FindAllAsync( GattDeviceService.GetDeviceSelectorFromUuid( GattServiceUuids.GenericAttribute ) );

This code doesn't throw an exception, but returns 0 devices.

Any Idea why?

In both case, the DeviceCapability is defined as follows:

    <m2:DeviceCapability Name="bluetooth.genericAttributeProfile">
        <m2:Device Id="any">
            <m2:Function Type="name:genericAttribute"/>
        </m2:Device>
    </m2:DeviceCapability>
1

1 Answers

4
votes

If you are working with Windows Phone 8.1 you are not able to enumerate the non paired devices. This changes with Windows 10 SDK release 1511