See BluetoothDevice.connectGatt()
. The description of autoConnect
is
boolean: Whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device becomes available (true).
What exactly does this do? If it is false
I suppose it must scan for the specific device for a short time, and give up if it is not found. But if it is true
what does it do? Does it start scanning immediately? Does it scan forever? Does it scan periodically? If it disconnects does it automatically reconnect? When is Google going to start writing decent documentation?
Edit: I have traced the parameter to bt_gatt_client.h
:
/** Create a connection to a remote LE or dual-mode device */
bt_status_t (*connect)(int server_if, const bt_bdaddr_t *bd_addr,
bool is_direct, int transport);
And a search for is_direct
turns up some interesting results.
Here is a slightly longer explanation, but it still doesn't answer any questions.
The autoConnect parameter determines whether to actively connect to the remote device, or rather passively scan and finalize the connection when the remote device is in range/available. Generally, the first ever connection to a device should be direct (autoConnect set to false) and subsequent connections to known devices should be invoked with the autoConnect parameter set to true.
I also found this definition of the Android 5 Bluetooth HCI requirements which contains many useful details, but still no real answer about how autoconnect is supposed to work.