Reputation: 300
To save embedded device battery power, the advertising period is 10sec. With a Samsung tablet, I succeed to scan the device with a scan period timeout of 30sec.
When I try to connect to it, nearly every time the connection is fail (error 133). Sometime it is OK. I already looked for some posts so I try to connect with the TRANSPORT_LE option. I suspect a timeout during the connection procedure because it stops after 2 or 3 second only.
How can I specify a longer timeout for the connectGatt() procedure?
Upvotes: 3
Views: 4908
Reputation: 88
Here is some method I address with status 133.
I add this code in callback
onConnectionStateChange
else if ((status == 8 && newState == 0) || (status == 133 && newState == 0)) {
gatt.disconnect();
gatt.close();
gatt.getDevice().connectGatt(getApplicationContext(), false, mGattCallback);
}
I just disconnect and release all bluetooth resource with gatt.close(). Then reconnect with it again.
Upvotes: 1