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
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.
To specify Bluetooth capability in the XML, right click on Package.appxmanifest and choose “Open With…” and then select “XML (Text) Editor)”.
and then you can add the ‘bluetooth’ capability (eg. for Universal Windows apps)
<DeviceCapability Name="bluetooth" />
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
Latest posts by Jim Wright (see all)
- Remote debug .NET applications over the internet with Visual Studio - November 14, 2016
- Craft and elegance in programming - May 19, 2016
- Bluetooth Low Energy in Windows 10: Troubleshooting Capabilities - August 31, 2015