bluetooth lowenergy - Why the App doesn't reconnect to the BLE device when set autoConnect to true in Android? -
i develop in android , ble. want app automatic reconnect ble device after ble device disconnect come in range , advertising.
i use following code connect ble device:
public void connect(final string address) { // todo auto-generated method stub log.w(tag, "bluetoothleservice connect function."); if(mbluetoothadapter == null || address == null){ log.w(tag, "bluetoothadapter not initialized or unspecified address."); //return false; } final bluetoothdevice device = mbluetoothadapter.getremotedevice(address); mbluetoothgatt = device.connectgatt(this, true, mgattcallback); }
i have set autoconnect
true
, didn't reconnect when ble device has disconnect , come in range.
why app doesn't reconnect ble device when set autoconnect true in android?
did missing ?
thanks in advance.
the auto connect parameter determines whether actively connect remote device (or) rather passively scan , finalize connection when remote device in range.
but not mean peripheral that's been disconnected days reappears reconnected.
generally, first ever connection device should direct (autoconnect set false) , subsequent connections known devices should invoked autoconnect parameter set true.
also please note, auto connect work when device still broadcasting. if not, not work.
i prefer re-connect manually when device disconnected. if in case end following this, need marker determine whether device disconnected without user consent.
if true unbind/unregister service/broadcast receiver , connect again using device address must have saved previously.
Comments
Post a Comment