[web-bluetooth] startNotifications sometimes doesn't bind (#429)

StephaneJuban has just created a new issue for https://github.com/WebBluetoothCG/web-bluetooth:

== startNotifications sometimes doesn't bind ==
Hi !

I have based my code according to the example of the heart rate measurement because I want to get value from a Characteristic in Notification mode.

Everything is working fine most of the time (9 out of 10 times). But sometimes, **even if the connection is successfully made**, when I try to bind to the notification, it doesn't work.

The subscription to the Notification is made in this function :
```
_startNotifications(characteristicUuid) {
    let characteristic = this._characteristics.get(characteristicUuid);
    console.log(characteristic);
    return characteristic.startNotifications().then(() => characteristic);
}
```

When everything is OK, I can see in the console that `BluetoothRemoteGATTCharacteristic` has a `value : DataView(2) {}` Otherwise, when it's not working it has a `value : null`

Console output :
![Image available here.](https://i.stack.imgur.com/MKPV0.png)

First, why do you think this happens ? Can this be because my BLE device is sending data/advertising too fast ?
I would like to be able to retry automatically, if I detect that the value is null for example.

How would you approach this ?

_I'm using Chrome but this happens on all device (Android smartphone, Mac, tablet)._
How would you approach this ?

Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/429 using your GitHub account

Received on Saturday, 23 March 2019 06:50:54 UTC