I have a C# (WPF) application that pairs with and gets data from a device using Bluetooth Low Energy, using the namespaces in UWP. I've been having intermittent problems (especially with the GetGattServicesAsync
call, e.g. occasionally hanging), but it works fine most of the time.
Anyway, many sources that turn up in my research state that a Package.appxmanifest
file is required, containing the Bluetooth DeviceCapability
.
However, this puzzles me - I have a BLE testing application (Command Line application) that works fine (for the most part) without it, as does my main WPF application. Also, if I add it to my project, it doesn't seem to do anything to improve my intermittent problems.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="Vitalograph.Spirotrac.RemoteTablet"
Version="2.0.21"
Publisher="Vitalograph" />
<Properties>
<DisplayName>Spirotrac Remote Tablet</DisplayName>
<PublisherDisplayName>Vitalograph</PublisherDisplayName>
<Logo></Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="en-gb" />
</Resources>
<Applications>
<Application Id="Vitalograph.Spirotrac.RemoteTablet" StartPage="default.html">
<VisualElements DisplayName="Spirotrac Remote Tablet" Description="Spirotrac Remote Tablet"
Logo="" SmallLogo=""
ForegroundText="dark" BackgroundColor="#FFFFFF">
<SplashScreen Image="" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<m2:DeviceCapability Name="bluetooth.genericAttributeProfile">
<m2:Device Id="any">
<m2:Function Type="serviceId:46A970E0-0D5F-11E2-8B5E-0002A5D5C51B"/>
<m2:Function Type="name:heartRate"/>
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
</Package>
I got this info from Microsoft's page on creating a basic package manifest and added the Bluetooth capability.
So do I need it or not? What does it do, if BLE / UWP works without it? Also, my Bluetooth functionality is in a separate project in my solution that compiles as a DLL, should it be added to that project or my main (Startup) .exe project? Does the build need to "Copy to Output Directory"?
Edit
I've updated the code of the manifest file to reflect the link from Jimi. I've also ensured that the manifest file is copied to the build folder. However I'm not seeing any change in behaviour.
This is a summary of the question. The package manifest is an XML document that contains the info the system needs to deploy, display, or update a Windows app. This info includes package identity, package dependencies, required capabilities, visual elements, and extensibility points.
If you need to package and distribute your desktop application, the project needs Package.appxmanifest, it has no effect on the function of the Bluetooth API for desktop application. It is recommended find the reason for the disconnection from the log.