iDevicesInc / SweetBlue

BLE on Android, the easy way. THIS IS NOW DEPRECATED. Please visit website for info on new versions.
https://sweetblue.io
GNU General Public License v3.0
357 stars 57 forks source link

Reconnect issues with status 133 #441

Closed rkhines closed 6 years ago

rkhines commented 6 years ago

Hi Sweetblue team,

We are seeing reconnect issues on some of our beta test devices where, after loosing the connection for some reason (out of range, airplane mode, etc.), the system fails to reconnect. The failure seems to be at least somewhat device dependant, as it is common on a Samsung Galaxy S8 (Android 8.0.0) but we do not see the same issue on a Nexus 5X (also running Android 8.0.0)

We have the ReconnectFilter configured to retry indefinitely, and in the logs we see it retry continuously, but every attempt fails almost immediately with a gatt status 133. In one case, the device failed 171 times to reconnect before finally succeeding. This particular reconnect failure is one we have seen before, and one of the reason we moved to using Sweetblue in hopes that it would help alleviate some of these issues.

Is there some configuration we may be missing that may help us in this case?

Should we be detecting these failures and prompting the user to reset the BleManager?

Any suggestions you can provide would be greately appreciated.

ryanhubbell commented 6 years ago

Yeah, sometimes the ble stack just gets into a state where it doesn't want to work very well. This is usually indicated by a bunch of gatt status 133 errors. Typically, recycling bluetooth will help alleviate them (calling BleManager.reset()).

rkh14o commented 6 years ago

Thanks for the response.

In my travels I have run into a post that mentions a connectGatt method that takes a fourth transport parameter. Using that method with BluetoothDevice.TRANSPORT_LE seemed to help with status 133 errors. I know it is possible to set the transport in Sweetblue for bonding (useLeTransportForBonding), but I did not see anywhere to set LE Transport for connecting.

Is that used automatically in Sweetblue? Is it configurable?

Thanks

ryanhubbell commented 6 years ago

It's already being used by SweetBlue. It is not currently configurable. This is a BLE library after all, and I dont see why you'd want to change it to anything else.

rkh14o commented 6 years ago

Makes sense :)

Thanks.