Re: [web-bluetooth] Should connectGATT() time out or wait until a device is available?

I assume the recommendation "use direct connect for first connection, 
and re-connections with auto" is simply because that the default scan 
parameters are more active for direct connect, and it has a built-in 
timeout, which are usually two nice things if you want to have a 
simple UI to scan and connect a BLE device.

Regarding having multiple direct connections and aborting connections,
 you should be aware of this bug on Android:
https://code.google.com/p/android/issues/detail?id=228633

Anyway, I find it very annoying the Android team has decided not to 
use the white list for "direct connect" because a direct connect 
blocks away all other pending connections.

For the actual initial question, I think connectGATT should simply 
wait until the device has connected (no timeout). If someone wants a 
timeout, it's easy to set up one using setTimeout in javascript and 
disconnect upon timeout. Thanks to javascript's single threading you 
can be sure you won't get any spurious connected event right after a 
disconnect command (which is a common race condition in other 
multi-threaded languages).

-- 
GitHub Notification of comment by Emill
Please view or discuss this issue at 
https://github.com/WebBluetoothCG/web-bluetooth/issues/152#issuecomment-263596340
 using your GitHub account

Received on Tuesday, 29 November 2016 15:12:04 UTC