mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-30 22:20:30 +10:00
addressed copilot issues still need pr #301 for smoke tests to pass
This commit is contained in:
@@ -1701,7 +1701,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
remoteId,
|
remoteId,
|
||||||
);
|
);
|
||||||
final needsBondRecovery =
|
final needsBondRecovery =
|
||||||
pluginBondState != BmBondStateEnum.bonded || !trustedByBluez;
|
(pluginBondState != null &&
|
||||||
|
pluginBondState != BmBondStateEnum.bonded) ||
|
||||||
|
!trustedByBluez;
|
||||||
if (!needsBondRecovery) {
|
if (!needsBondRecovery) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1770,6 +1772,11 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
'bluetoothctl unavailable; continuing with plugin bonded state',
|
'bluetoothctl unavailable; continuing with plugin bonded state',
|
||||||
tag: 'BLE Connect',
|
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 {
|
} else {
|
||||||
_appDebugLogService?.warn(
|
_appDebugLogService?.warn(
|
||||||
'bluetoothctl unavailable and device is not bonded; skipping Linux pairing fallback',
|
'bluetoothctl unavailable and device is not bonded; skipping Linux pairing fallback',
|
||||||
@@ -1817,6 +1824,8 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_appDebugLogService?.info(
|
_appDebugLogService?.info(
|
||||||
beforeBondState == BmBondStateEnum.bonded
|
beforeBondState == BmBondStateEnum.bonded
|
||||||
? 'Linux BLE device still untrusted after repair; requesting pair'
|
? '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',
|
: 'Linux BLE device not bonded, requesting pair',
|
||||||
tag: 'BLE Connect',
|
tag: 'BLE Connect',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ typedef ProcessRunFn =
|
|||||||
/// This is used only as a fallback when BlueZ pairing via flutter_blue_plus
|
/// This is used only as a fallback when BlueZ pairing via flutter_blue_plus
|
||||||
/// fails to surface agent prompts in-app.
|
/// fails to surface agent prompts in-app.
|
||||||
class LinuxBlePairingService {
|
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.
|
/// 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 _processExitTimeout = Duration(seconds: 6);
|
||||||
static const Duration _pairingCleanupTimeout = Duration(seconds: 5);
|
static const Duration _pairingCleanupTimeout = Duration(seconds: 5);
|
||||||
@@ -110,7 +110,7 @@ class LinuxBlePairingService {
|
|||||||
var proactivePinRetryUsed = false;
|
var proactivePinRetryUsed = false;
|
||||||
Future<String?> Function()? currentPinProvider = onRequestPin;
|
Future<String?> Function()? currentPinProvider = onRequestPin;
|
||||||
|
|
||||||
for (var attempt = 0; attempt <= _maxRetries; attempt++) {
|
for (var attempt = 0; attempt < _maxAttempts; attempt++) {
|
||||||
final result = await _runPairingAttempt(
|
final result = await _runPairingAttempt(
|
||||||
remoteId: remoteId,
|
remoteId: remoteId,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
@@ -129,7 +129,7 @@ class LinuxBlePairingService {
|
|||||||
removeRetryUsed = true;
|
removeRetryUsed = true;
|
||||||
onLog?.call(
|
onLog?.call(
|
||||||
'Pairing failed; removing cached bond and retrying '
|
'Pairing failed; removing cached bond and retrying '
|
||||||
'(attempt ${attempt + 1}/$_maxRetries)',
|
'(attempt ${attempt + 1}/$_maxAttempts)',
|
||||||
);
|
);
|
||||||
await _removeDevice(remoteId, onLog: onLog);
|
await _removeDevice(remoteId, onLog: onLog);
|
||||||
continue;
|
continue;
|
||||||
@@ -140,7 +140,7 @@ class LinuxBlePairingService {
|
|||||||
proactivePinRetryUsed = true;
|
proactivePinRetryUsed = true;
|
||||||
onLog?.call(
|
onLog?.call(
|
||||||
'Pairing failed before PIN challenge; requesting PIN for '
|
'Pairing failed before PIN challenge; requesting PIN for '
|
||||||
'proactive retry (attempt ${attempt + 1}/$_maxRetries)',
|
'proactive retry (attempt ${attempt + 1}/$_maxAttempts)',
|
||||||
);
|
);
|
||||||
final pin = await currentPinProvider();
|
final pin = await currentPinProvider();
|
||||||
if (pin == null) {
|
if (pin == null) {
|
||||||
@@ -162,7 +162,7 @@ class LinuxBlePairingService {
|
|||||||
proactivePinRetryUsed = true;
|
proactivePinRetryUsed = true;
|
||||||
onLog?.call(
|
onLog?.call(
|
||||||
'No PIN challenge observed before timeout; requesting PIN for '
|
'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();
|
final pin = await currentPinProvider();
|
||||||
if (pin == null) {
|
if (pin == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user