The problem

When implementing BLE in a Windows Runtime or Universal Windows app, using BluetoothLEAdvertisementWatcher (or BluetoothLEAdvertisementPublisher), you may find that the instance stops immediately after you start it, with the status

bluetoothLEAdvertisemenetWatcher.Status == BluetoothLEAdvertisementWatcherStatus.Aborted

The reason for the watcher or publisher stopping may be that your app has not specified the capabilities that it requires from the device (it’s not easy to tell, because there doesn’t appear to be any information as to what caused the status change – you’re not surprised by this, are you?).

If you’re new to Windows Runtime or Universal Windows apps; capabilities are device features that your app needs.  You specify them in a manifest file, but bear in mind that the capabilites you desire may be non-existent on the device (eg the  device doesn’t have Bluetooth Low Energy) or be blocked by security policies for example.  Also see https://msdn.microsoft.com/en-us/library/windows/apps/dn263090.aspx

The fix

To avoid the problem of the watcher/publisher immediately stopping (being aborted), specify in the Package.appxmanifest that the ‘bluetooth’ DeviceCapability is required.  Although Package.appxmanifest appears to have a good graphical UI (in VS 2015), you cannot actually specify the ‘bluetooth’ capability from the GUI (strange, I know), you must do it in the actual XML.

Package.appxmanifest UI Editor
Bluetooth?

To specify Bluetooth capability in the XML, right click on Package.appxmanifest and choose “Open With…” and then select “XML (Text) Editor)”.

Opening the Package.appxmanifest with the XML editor
Opening the Package.appxmanifest with the XML editor

and then you can add the ‘bluetooth’ capability (eg. for Universal Windows apps)

after the <Applications> element (eg. before </Package>).  For Windows Runtime, see the Microsoft link above.

You can read more about capabilities in general here http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html

 

 

One thought on “Bluetooth Low Energy in Windows 10: Troubleshooting Capabilities”

Leave a Reply

Your email address will not be published. Required fields are marked *