mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
addressed copilot issues still need pr #301 for smoke tests to pass
This commit is contained in:
parent
29660d520e
commit
990f2bd33d
2 changed files with 16 additions and 7 deletions
|
|
@ -1701,7 +1701,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
remoteId,
|
||||
);
|
||||
final needsBondRecovery =
|
||||
pluginBondState != BmBondStateEnum.bonded || !trustedByBluez;
|
||||
(pluginBondState != null &&
|
||||
pluginBondState != BmBondStateEnum.bonded) ||
|
||||
!trustedByBluez;
|
||||
if (!needsBondRecovery) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1770,6 +1772,11 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
'bluetoothctl unavailable; continuing with plugin bonded state',
|
||||
tag: 'BLE Connect',
|
||||
);
|
||||
} else if (beforeBondState == null) {
|
||||
_appDebugLogService?.warn(
|
||||
'bluetoothctl unavailable and plugin bond state is unknown; skipping Linux pairing fallback',
|
||||
tag: 'BLE Connect',
|
||||
);
|
||||
} else {
|
||||
_appDebugLogService?.warn(
|
||||
'bluetoothctl unavailable and device is not bonded; skipping Linux pairing fallback',
|
||||
|
|
@ -1817,6 +1824,8 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
_appDebugLogService?.info(
|
||||
beforeBondState == BmBondStateEnum.bonded
|
||||
? 'Linux BLE device still untrusted after repair; requesting pair'
|
||||
: beforeBondState == null
|
||||
? 'Linux BLE device bond state unknown; requesting pair'
|
||||
: 'Linux BLE device not bonded, requesting pair',
|
||||
tag: 'BLE Connect',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ typedef ProcessRunFn =
|
|||
/// This is used only as a fallback when BlueZ pairing via flutter_blue_plus
|
||||
/// fails to surface agent prompts in-app.
|
||||
class LinuxBlePairingService {
|
||||
/// Maximum number of retry attempts for the pairing flow.
|
||||
/// Maximum number of pairing attempts (initial + retries).
|
||||
/// Covers one remove-and-retry plus one proactive-PIN retry.
|
||||
static const int _maxRetries = 2;
|
||||
static const int _maxAttempts = 3;
|
||||
|
||||
static const Duration _processExitTimeout = Duration(seconds: 6);
|
||||
static const Duration _pairingCleanupTimeout = Duration(seconds: 5);
|
||||
|
|
@ -110,7 +110,7 @@ class LinuxBlePairingService {
|
|||
var proactivePinRetryUsed = false;
|
||||
Future<String?> Function()? currentPinProvider = onRequestPin;
|
||||
|
||||
for (var attempt = 0; attempt <= _maxRetries; attempt++) {
|
||||
for (var attempt = 0; attempt < _maxAttempts; attempt++) {
|
||||
final result = await _runPairingAttempt(
|
||||
remoteId: remoteId,
|
||||
timeout: timeout,
|
||||
|
|
@ -129,7 +129,7 @@ class LinuxBlePairingService {
|
|||
removeRetryUsed = true;
|
||||
onLog?.call(
|
||||
'Pairing failed; removing cached bond and retrying '
|
||||
'(attempt ${attempt + 1}/$_maxRetries)',
|
||||
'(attempt ${attempt + 1}/$_maxAttempts)',
|
||||
);
|
||||
await _removeDevice(remoteId, onLog: onLog);
|
||||
continue;
|
||||
|
|
@ -140,7 +140,7 @@ class LinuxBlePairingService {
|
|||
proactivePinRetryUsed = true;
|
||||
onLog?.call(
|
||||
'Pairing failed before PIN challenge; requesting PIN for '
|
||||
'proactive retry (attempt ${attempt + 1}/$_maxRetries)',
|
||||
'proactive retry (attempt ${attempt + 1}/$_maxAttempts)',
|
||||
);
|
||||
final pin = await currentPinProvider();
|
||||
if (pin == null) {
|
||||
|
|
@ -162,7 +162,7 @@ class LinuxBlePairingService {
|
|||
proactivePinRetryUsed = true;
|
||||
onLog?.call(
|
||||
'No PIN challenge observed before timeout; requesting PIN for '
|
||||
'proactive retry (attempt ${attempt + 1}/$_maxRetries)',
|
||||
'proactive retry (attempt ${attempt + 1}/$_maxAttempts)',
|
||||
);
|
||||
final pin = await currentPinProvider();
|
||||
if (pin == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue