mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 10:55:49 +01:00
Pebble: change delay between reconects to 1,2,4,8,16,32,64 (max) seconds
This commit is contained in:
parent
4055cc1173
commit
e91b5a07bd
@ -365,18 +365,21 @@ 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());
|
||||
int delaySeconds = 1;
|
||||
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);
|
||||
Thread.sleep(delaySeconds * 1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
if (delaySeconds < 64) {
|
||||
delaySeconds *= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user