-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a "connectable" field to BluetoothDevice #253
Comments
What should BluetoothDevice.connectable return on Android, where we don't know if a device is sending connectable advertisements? I think we could leave it Also, what do you mean by "be opposed the fact that we can pre-filter devices"? |
Thanks @jyasskin good point! Sorry for missing Android issue.. indeed I'd be happy with a nullable Sorry for the "be opposed the fact that we can pre-filter devices" : I meant that we can also say that provided we have a filter to return only connectable devices, then we don't need the boolean. |
I think it might be confusing for developers to have this member if android doesn't support it. Imagine a developer on macOS that writes the following line: if (device.connectable) {
return device.gatt.connect();
} That will work while he's developing but fail on real android devices. |
oops yes indeed @g-ortuno ... that doesn't solve our limitations |
In each BLE ADV_IND advert there is the Flags AD type (Although it is arguably optional to include it) the Flags AD type also indicates if the device is in pairing mode (because one or both of the discoverable bits are set), it is probably useful if that information is also propagated up to the browser API. |
@pzboyz Do you have any use cases in mind? It would help if we had use cases to know if such a feature is useful or not. |
The Android Bluetooth API's scan results do indicate if the advertisement indicated connectable or not: https://developer.android.com/reference/android/bluetooth/le/ScanResult.html#isConnectable() . This API is available since Android 8.0 aka API Level 26. However, please be aware the the Bluetooth spec allows for a device to interleave connectable and non-connectable advertisement, and in fact this is commonly used with beacons. It may make more sense to stick closer to the spec, and indicate connectability per advertisement packet, rather than per device. |
Oh nice. Agree that having it as part of the adv packet event would be better. We still need to figure out what to return on older versions of Android though. |
As @beaufortfrancois suggests (following @Vudentz remark) in pull-request #239 , it would be valuable to add a
boolean connectable
member toBluetoothDevice
.Instances of
BluetoothDevice
return by a regularrequestLEScan
(the one without explicitly filtering out connectable devices) have no hint whether or not we can connect to their GATT server.Once we get device from
requestDevice
, such aBluetoothDevice
instance would also hold sameboolean connectable
member. Subsequent call to.gatt.connect()
would fail ifconnectable
isfalse
...oh and I already acknowledge I'll be opposed the fact that we can pre-filter devices (see #243)
The text was updated successfully, but these errors were encountered: