Skip to content
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

Open
jracle opened this issue Jul 26, 2016 · 8 comments
Open

Add a "connectable" field to BluetoothDevice #253

jracle opened this issue Jul 26, 2016 · 8 comments

Comments

@jracle
Copy link

jracle commented Jul 26, 2016

As @beaufortfrancois suggests (following @Vudentz remark) in pull-request #239 , it would be valuable to add a boolean connectable member to BluetoothDevice.

Instances of BluetoothDevice return by a regular requestLEScan (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 a BluetoothDevice instance would also hold same boolean connectable member. Subsequent call to .gatt.connect() would fail if connectable is false.

..oh and I already acknowledge I'll be opposed the fact that we can pre-filter devices (see #243)

@jyasskin
Copy link
Member

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 false or allow it to be null.

Also, what do you mean by "be opposed the fact that we can pre-filter devices"?

@jracle
Copy link
Author

jracle commented Jul 28, 2016

Thanks @jyasskin good point! Sorry for missing Android issue.. indeed I'd be happy with a nullable boolean? connectable.

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.

@g-ortuno
Copy link
Contributor

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.

@jracle
Copy link
Author

jracle commented Jul 28, 2016

oops yes indeed @g-ortuno ... that doesn't solve our limitations

@pzboyz
Copy link

pzboyz commented Jul 28, 2016

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.

@g-ortuno
Copy link
Contributor

@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.

@jyasskin jyasskin added this to the Complete GATT Communication milestone Sep 7, 2016
@mkv123
Copy link

mkv123 commented Aug 20, 2018

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.

@g-ortuno
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants