0
votes

In a UWP application (SDK target Anniversary Update) I'm having a very annoying problem.

I have a Bluetooth Low Energy device which I connect without problems (both PC and Mobile platforms), read/write operations on GATT services and characteristics works, but the background task with GattCharacteristicNotificationTrigger trigger for battery status notification is not reliable at all.

As long as I register the task for the first time, this works fine, but when

  1. I turn off / restart the device that connects (UWP GATT client)

or

  1. I turn off / restart the BLE device (GATT Server)

The task stop running, until the application is reopened in foreground and the task is re-registered.

It's an operation not at all comfortable especially if I always want to know the battery status, and using a TimerTrigger is not really the best being triggered at least every 15 minutes.

I tried to find more information about the trigger in question but I did not find anything.

I'm doing something wrong? (the trigger is meant to stop when one of the two devices turn off?)

P.S .: I tried, for scruple, to record the task both in classic way (out of process, in separate Windows Runtime component) and the new one introduced with the Anniversary Update in process, but nothing has changed.

Thank you in advance.

1

1 Answers

0
votes

This is normal behavior, when a connection is lost for whatever reason the server will break the connection after a few seconds and loose all connecting information and start advertising again, so any client can discover, connect or reconnect. The best way to deal with this is to make a disconnected event and on-disconnect: dispose the device, create new device, connect en re-register for notifications.