I'm trying to develop an app that connects via BLE to my CC2650 sensor tag from Texas.
I'm able to connect to my tag using GATT protocol the problem is that if when I'm connected the connection fails it is not restored. But if I reconnect the phone to the device and I repeat the procedure (turn off and on the tag) it automatically reconnects to the phone.
I just don't understand the difference between the first behavior and the one after a reconnection...
Any idea?
Alex
Android should be documented better. Anyway, here is the explanation:
When you call connectGatt (https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback)) with autoConnect set to false, that will only make a one-shot connection to the device. When it disconnects, it doesn't reconnect.
When you instead connect using the .connect() method on the BluetoothGatt object, that is the same thing as closing the current BluetoothGatt object and then connect again with connectGatt and the autoConnect parameter set to true.
When the autoConnect parameter is set to true, that means that you would like to keep the device connected forever, i.e. for whatever reason it disconnects, Android will always try to attempt to reconnect to the device.
You can check out my list of differences for autoConnect here: https://stackoverflow.com/a/40187086/556495.