1

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.

5
  • How to specify device capabilities for Bluetooth Commented Feb 25 at 13:48
  • @Jimi - thanks, it's slightly different to what's specified elsewhere. I've updated accordingly (had to search for the namespace for m2 - wasn't in the above link) - but my question stands. Commented Feb 25 at 14:28
  • The manifest plays a role in the (UWP) "store model"; where apps have to "declare" the things they do; like: "Will access your internet connection"; in which case, there is no obvious effect. Commented Feb 25 at 18:54
  • 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.How to collect Bluetooth logs Commented Feb 26 at 2:08
  • Interesting! Any of the sources which advise to add one don't point out this detail! ChatGPT (yes, I know) even suggests it as a solution to one exception I was getting! Commented Feb 26 at 10:05

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.