-
Notifications
You must be signed in to change notification settings - Fork 354
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
Automatic reconnect #214
Comments
You could call the reconnect function when a disconnected event is receive. |
If it disconnected because the phone and device got too far away, will the reconnect function make sure to connect as soon as they are within reach again? |
I haven't verified the specific behavior, but it should. Calling the plugins reconnect method calls this internally on Android: http://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#connect() while iOS just uses the standard connect method. Neither of them timeout and should automatically connect when the device is within range again. Based on what I've seen with Android so far, I prefer to completely disconnect and close the connection, wait a small timeout and then call connect again rather than reconnect. |
Sounds great, thanks! |
iOS must be discovered on reconnect according to what I added to the README a while back, but I haven't reverified this lately. I can't say exactly what the cost of closing the connection is. The Android Bluetooth stack can be pretty buggy, so I prefer to completely close out the connection. I would test it out and see what works best for you. Just keep in mind that Bluetooth "reliability" seems to vary between Android devices, which is partially why you'll see so many issues. :) |
Hello,
I need to have the phone automatically reconnect to the device after a disconnect and when it is within reach again. At least the "connectGatt" method on Android comes with a autoConnect parameter, but this is hardcoded to "false" in the plugin.
I am wondering if there is a reason for not supporting this parameter in Javascript? To me it looks like exactly the behaviour I need. Does iOS support that behaviour too?
The text was updated successfully, but these errors were encountered: