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?
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>