Bluetooth Low Energy Multiply times ValueChanged notification

Vladi 25 Reputation points

The GattCharacteristic.ValueChanged event handler is triggered multiple times. The same problem with "Windows-universal-samples" in "BluetoothLE" example.

BluetoothLE" example...

For example when I "connect to device"--> Select Service --> Select Characteristic --> (click on) "Subscribe for notification" first time its works OK.

Then I disconnect from device and make new connect "connect to device"--> Select Service --> Select Characteristic --> (click on) "Subscribe for notification" the ValueChanged is Triggered twice an any single notification from BLE device,

Also any click "Unsubscribe / Subscribe to value changes" in demo add one more times to ValueChanged evens 3,4,5,6 times per each notification.

The main my problem when I connect /disconnect form device (when my code dispose BluetoothLEDevice instance).

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,636 questions
Universal Windows Platform (UWP)
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,010 questions
{count} votes

Accepted answer
  1. Roy Li - MSFT 29,866 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    I've checked the code in the Bluetooth sample that you've mentioned. That's an unexpected behavior and the code you found is the reason causing the behavior.

    I've reported this via our channel that there is a mistake in the Bluetooth sample for subscription. Please also submit an issue in the Issues of the GitHub:

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Vladi 25 Reputation points

    Hi. I found the bug in the "Windows-universal-samples" "BluetoothLE" sample...

    In "ValueChangedSubscribeToggle_Click()" I just comment the "subscribedForNotifications = false;" line. It placed before 'RemoveValueChangedHandler()' and RemoveValueChangedHandler do nothing when subscribedForNotifications is false...

    Best regards.


    1 person found this answer helpful.