-
Notifications
You must be signed in to change notification settings - Fork 87
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
Set transport flag to BluetoothDevice.TRANSPORT_LE by default #61
Comments
Hi! 👋
For Able, we never had a need to customize it, so just never focused on that code. Android BLE is notoriously error prone when it comes to characteristic (and friends) objects because the Android system shares with you the same instances of In newer versions of Android, you can use a In Kable, we wanted to utilize This particular parameter was introduced in Kable to fix a separate issue. 😄
We'll have to look into it, but we'll want to have the default be whatever the default/expected behavior would be across all the supported platforms (or as consistent as we can get that).
Definitely, so even if the default isn't what you'd typically use, you'll be able to configure it to your needs.
Thanks, really appreciate the kind words. We're planning to write a small migration guide soon that might help you out with the transition (#50). |
It's a bit difficult to find conclusive details about how Apple and JavaScript handle this, but it seems Apple (Core Bluetooth) will "choose to use the BR/EDR transport if available" and "In the CB [Core Bluetooth] API there is no indication whatsoever that BR/EDR is used. Also, there's no way to specify which transport to use". — NordicSemiconductor/IOS-nRF-Connect#66 (comment) The JavaScript documentation talked about support for BR/EDR but (similar to Core Bluetooth) there doesn't seem to be a way to choose. Since it seems that Apple and JavaScript both exhibit a behavior akin to I'll expose a way on the API to configure this option for Android platform/consumers. Happy to reconsider if you can find evidence of it being configurable and/or a different default on JavaScript and Apple. |
Sadly I cannot provide any info on how JavaScript or Apple handles this. I also don't have a full picture of what the different modes will do for different devices and in different situations. My only thought was that since this is a library targeting a BLE connection, it could default to whats best for each platform when it comes to BLE as long as behaviour more or less stays the same. And it seems that using On one hand I can totally understand the goal of having all platforms behave the same but on the other hand I could see most consumers will want to change this flag for their android implementations. Sidenote: For what its worth, Nordic only uses |
@degill I definitely hear you. Also totally understand only having "anecdotal evidence", BLE is such a complex beast (especially on Android) that many times people just gain experience with getting things to work a specific way (without actually being able to prove why it works better, due to things being so complex and hard to definitively prove). I'll mull over this a bit more before making a final decision. Not sure how to approach this, but if you happen to come up with some way (ideally via some test code w/ results) to prove that |
If I find the time I will try to do some more research. The complexity and the lack of docs and explanations is just a bummer. Regarding the prove you mentioned: I can (sadly) not share our current project with you (it wouldn't help much either I guess because we develop our own hardware) but I definitely had a dramatic decrease in failed connection attempts with a |
Looking through the Android source, // Determine transport
if (transport_p != BT_TRANSPORT_AUTO) {
transport = transport_p;
} else {
switch (device_type) {
case BT_DEVICE_TYPE_BREDR:
transport = BT_TRANSPORT_BR_EDR;
break;
case BT_DEVICE_TYPE_BLE:
transport = BT_TRANSPORT_LE;
break;
case BT_DEVICE_TYPE_DUMO:
if (transport_p == BT_TRANSPORT_LE)
transport = BT_TRANSPORT_LE;
else
transport = BT_TRANSPORT_BR_EDR;
break;
}
} Determining where Skimming through various parts of the source for how I had originally assumed that the ...I'll continue to do a bit of research. I'll also see what I can find out about the other platforms (Core Bluetooth and Web Bluetooth) to determine their default behavior. |
I am also for setting default transport to TRANSPORT_LE |
@solvek Thanks for voicing interest in this issue. I've been swamped with other work related tasks, but I'll try to dedicate some time to Kable this weekend to get this (and hopefully a few other issues) wrapped up for the next release. In the mean time, to use your fork of Kable in your project: there are a number of ways of approaching it, but for quick testing and local usage, performing a local Maven install might be what you're looking for?
The above command will publish to your Maven local as version Then in your Gradle project where you want to use your forked version: repositories {
mavenLocal()
// ..
}
// depending on your project configuration, you may need to place this in the appropriate sourceSet directive
dependencies {
implementation("com.juul.kable:core:main-SNAPSHOT")
} |
A repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
implementation("com.juul.kable:core:0.4.1-issue-61-SNAPSHOT")
} The import com.juul.kable.Transport.Le
import com.juul.kable.Phy.Le1M
val peripheral = scope.peripheral(advertisement, transport = Le, phy = Le1M)
peripheral.connect() The transport default is currently Auto. Further investigation is needed to how Core Bluetooth (e.g. iOS) handles the transport distinction (before providing a similar API for Apple targets). For now, Please give the |
📢 UPDATE: Looked into it a bit more, it appears that Web Bluetooth doesn't support non-LE profiles. With Core Bluetooth (e.g. iOS) not allowing for customization of the transport it didn't feel as necessary to default to In other words, |
Support for configuring transport (with default as LE) added in 0.5.0. |
Hello there :)
Currently I am still using able, or better: I am using a slightly customised version of it where I set the
transport flag of the connectGatt
method toBluetoothDevice.TRANSPORT_LE
.I was wondering what the reasoning behind this decision is. Using
BluetoothDevice.TRANSPORT_LE
might reduce the appearances of the infamous133
error. Other then anecdotal once I sadly have no proof to back up this claim.I saw that you want to make this a customisable parameter, still I am wondering why in Able you didn't use the flag and here you use
TRANSPORT_AUTO
.Also: Great library, really looking forward to incorporating Kable at one point :)
The text was updated successfully, but these errors were encountered: