mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-26 09:37:33 +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());
|
LOG.info(e.getMessage());
|
||||||
mIsConnected = false;
|
mIsConnected = false;
|
||||||
int reconnectAttempts = Integer.valueOf(sharedPrefs.getString("pebble_reconnect_attempts", "10"));
|
int reconnectAttempts = Integer.valueOf(sharedPrefs.getString("pebble_reconnect_attempts", "10"));
|
||||||
int maxReconnectAttempts = reconnectAttempts;
|
|
||||||
if (reconnectAttempts > 0) {
|
if (reconnectAttempts > 0) {
|
||||||
gbDevice.setState(GBDevice.State.CONNECTING);
|
gbDevice.setState(GBDevice.State.CONNECTING);
|
||||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||||
|
int delaySeconds = 1;
|
||||||
while (reconnectAttempts-- > 0 && !mQuit && !mIsConnected) {
|
while (reconnectAttempts-- > 0 && !mQuit && !mIsConnected) {
|
||||||
LOG.info("Trying to reconnect (attempts left " + reconnectAttempts + ")");
|
LOG.info("Trying to reconnect (attempts left " + reconnectAttempts + ")");
|
||||||
mIsConnected = connect(gbDevice.getAddress());
|
mIsConnected = connect(gbDevice.getAddress());
|
||||||
if (!mIsConnected) {
|
if (!mIsConnected) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep((maxReconnectAttempts-reconnectAttempts)*1000);
|
Thread.sleep(delaySeconds * 1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
|
if (delaySeconds < 64) {
|
||||||
|
delaySeconds *= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user