2

J'écris une application Windows 10 UWP sur mon Surface Pro 3 qui est connecté à mon Microsoft Band 2 et je peux me connecter ça va très bien quand je cours l'application au premier plan. Mais maintenant j'essaye d'utiliser le DeviceUseTrigger et d'exécuter de la logique dans une tâche d'arrière-plan. Quand j'appelle la méthode pour se connecter à la bande:Microsoft Band 2 + UWP + Tâche de fond => Une erreur est survenue lors de la tentative d'acquisition du service de périphérique Bluetooth

var bandInfo = (await BandClientManager.Instance.GetPairedBandsAsync()).FirstOrDefault(); 
var bandClient = await BandClientManager.Instance.ConnectAsync(bandInfo); 

Je reçois l'erreur suivante:

An error occurred while attempting to acquire the Bluetooth device service. This error can occur if the paired device is unreachable or has become unpaired from the current host.

J'ai ajouté les fonctionnalités suivantes à mon UWP appxmanifest:

<DeviceCapability Name="bluetooth" /> 
<DeviceCapability Name="location" /> 
<DeviceCapability Name="proximity" /> 
<DeviceCapability Name="bluetooth.rfcomm"> 
    <Device Id="any"> 
    <Function Type="serviceId:A502CA9A-2BA5-413C-A4E0-13804E47B38F" /> 
    <Function Type="serviceId:C742E1A2-6320-5ABC-9643-D206C677E580" /> 
    </Device> 
</DeviceCapability> 

Et ce est ma déclaration de la tâche d'arrière-plan:

<Extensions> 
    <Extension Category="windows.backgroundTasks" EntryPoint="WindowsRuntimeComponent1.BandBackgroundTask"> 
    <BackgroundTasks> 
     <Task Type="deviceUse" /> 
     </BackgroundTasks> 
    </Extension> 
</Extensions> 

Répondre

0

Juste une supposition, mais ce paragraphe de la Band SDK documentation peut-être aussi aider avec votre appel de GetPairedBandsAsync?

If your app wants to connect to the Band from the background, then the app should call GetBandsAsync(isBackground: true) to get a connection that will not interfere with any app that is running in the foreground and currently using a Band connection.

+0

Merci pour la réponse, j'ai raté cette partie de la documentation. J'ai changé cela maintenant, mais je reçois toujours la même erreur malheureusement. Je n'ai aucune idée de ce que je fais de mal ...: / –