diff --git a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart index 3b690079..526fbb10 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart @@ -377,13 +377,13 @@ Future connect(String id) async { ScanResult? result = results.where((element) => element.device.remoteId.str == id).firstOrNull; if (result != null) { int retry = 0; - while (retry < 3) { + while (retry < HiveProxy.getOrDefault(settings, gearConnectRetryAttempts, defaultValue: gearConnectRetryAttemptsDefault)) { try { await result.device.connect(); break; } on FlutterBluePlusException catch (e) { retry = retry + 1; - _bluetoothPlusLogger.warning("Failed to connect to ${result.device.advName}. Attempt $retry/3", e); + _bluetoothPlusLogger.warning("Failed to connect to ${result.device.advName}. Attempt $retry/${HiveProxy.getOrDefault(settings, gearConnectRetryAttempts, defaultValue: gearConnectRetryAttemptsDefault)}", e); await Future.delayed(Duration(milliseconds: 250)); } } diff --git a/lib/Frontend/pages/developer/developer_menu.dart b/lib/Frontend/pages/developer/developer_menu.dart index 7f4c1e1b..0bf9bc6c 100644 --- a/lib/Frontend/pages/developer/developer_menu.dart +++ b/lib/Frontend/pages/developer/developer_menu.dart @@ -123,6 +123,21 @@ class _DeveloperMenuState extends ConsumerState { }, ), ), + ListTile( + title: const Text(gearConnectRetryAttempts), + subtitle: Slider( + divisions: 29, + max: 30, + min: 1, + label: HiveProxy.getOrDefault(settings, gearConnectRetryAttempts, defaultValue: gearConnectRetryAttemptsDefault).toString(), + value: HiveProxy.getOrDefault(settings, gearConnectRetryAttempts, defaultValue: gearConnectRetryAttemptsDefault).toDouble(), + onChanged: (double value) async { + setState(() { + HiveProxy.put(settings, gearConnectRetryAttempts, value.toInt()); + }); + }, + ), + ), ListTile( title: const Text(showDebugging), trailing: Switch( diff --git a/lib/constants.dart b/lib/constants.dart index 9358a6fa..7933ffc1 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -31,6 +31,7 @@ const String casualModeDelayMin = 'casualModeDelayMin'; const String casualModeDelayMax = 'casualModeDelayMax'; const String tailBlogWifiOnly = 'tailBlogWifiOnly'; const String triggerActionCooldown = 'triggerActionCooldown'; +const String gearConnectRetryAttempts = 'gearConnectRetryAttempts'; // Settings Default value const bool kitsuneModeDefault = false; @@ -55,6 +56,7 @@ const int casualModeDelayMinDefault = 15; const int casualModeDelayMaxDefault = 120; const bool tailBlogWifiOnlyDefault = false; const int triggerActionCooldownDefault = 15; +const int gearConnectRetryAttemptsDefault = 3; const String triggerBox = 'triggers'; const String sequencesBox = 'sequences';