mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Merge pull request #276 from roidelapluie/reconnect
Pebble: Smarter reconnection attempts
This commit is contained in:
commit
94cec55a20
@ -365,12 +365,19 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
LOG.info(e.getMessage());
|
||||
mIsConnected = false;
|
||||
int reconnectAttempts = Integer.valueOf(sharedPrefs.getString("pebble_reconnect_attempts", "10"));
|
||||
int maxReconnectAttempts = reconnectAttempts;
|
||||
if (reconnectAttempts > 0) {
|
||||
gbDevice.setState(GBDevice.State.CONNECTING);
|
||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||
while (reconnectAttempts-- > 0 && !mQuit && !mIsConnected) {
|
||||
LOG.info("Trying to reconnect (attempts left " + reconnectAttempts + ")");
|
||||
mIsConnected = connect(gbDevice.getAddress());
|
||||
if (!mIsConnected) {
|
||||
try {
|
||||
Thread.sleep((maxReconnectAttempts-reconnectAttempts)*1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mIsConnected && !mQuit) {
|
||||
|
Loading…
Reference in New Issue
Block a user