microsoft / Windows-universal-samples

API samples for the Universal Windows Platform.
MIT License
9.5k stars 7.98k forks source link

BluetoothLE GattCharacteristic ValueChanged event not firing #760

Open kirk-quinbar opened 6 years ago

kirk-quinbar commented 6 years ago

hi,

Not sure if this question is appropriate here but thought i'd start here at least. I am using the BluetoothLE sample as a starting place to connect to a Polar heartrate device, but ultimately i want the functionality in a desktop application. Using the WIndows 10 SDK (10.0.15063.0), I created a standalone class library to provide the functionality of connecting to this Polar device and i copied over parts of the sample code for the bluetoothLE Scenario2_Client.xaml.cs. I can get everything to work in the class library except no matter what ive tried i cannot get the ValueChanged event to fire when subscribed to the GattCharacteristic for the HeartRateMeasurement characteristic of the HeartRate service. if i run the bluetoothLE sample code, i can connect to the Polar device and can select that service and characteristic and the ValueChanged events fires as expected.

  1. Is it possible the Windows 10 SDK 10.0.15063.0 has issues with the bluetooth api? prior to the release of the creator's edition, i could get the valuechanged event to fire, but that was using an older version of the bluetooth api stuff and most of it stopped working once the windows creator edition was released, so i am having to rewrite it.

  2. I suppose its possible that there is something wrong with my code, but i did copy a lot of the basic connection and subscribing to the event from the bluetoothle sample. the only difference is that I am using a WPF app for the UI, but the bluetooth code should be very similar

this is my rewrite code. the HeartRateMonitor class is the basic implementation that connects to the Polar device, sets up the heartrate service and characteristic and subscribes to event, plus start the notify.

https://github.com/kirk-quinbar/HeartRateLE/tree/rewrite

been playing around with this for a week and so far cannot get the ValueChanged of the characteristic to fire as expected. driving me nuts. any thoughts on things to check for, or anyone is welcome to check out my code above for suggestions.

oldnewthing commented 6 years ago

I've asked the Bluetooth team to investigate.