|
|
|
@ -672,9 +672,10 @@ class PairingController extends GetxController with WidgetsBindingObserver { |
|
|
|
_verifiedDeviceAddress?.toUpperCase()) { |
|
|
|
// 已有关联,检查BLE连接状态 |
|
|
|
Logger.i(_tag, '设备已关联,检查BLE连接状态'); |
|
|
|
print('fdp--connectble--pairedMacAddress: $pairedMacAddress'); |
|
|
|
final currentBleState = await _bleManager.getConnectionState(); |
|
|
|
Logger.i(_tag, '验证时BLE状态: $currentBleState'); |
|
|
|
|
|
|
|
print('fdp--connectble--currentBleState: $currentBleState'); |
|
|
|
if (currentBleState == 2) { |
|
|
|
// BleConnectionState.connected |
|
|
|
Logger.i(_tag, 'BLE已连接,直接完成配对'); |
|
|
|
@ -701,21 +702,24 @@ class PairingController extends GetxController with WidgetsBindingObserver { |
|
|
|
} |
|
|
|
|
|
|
|
// Logger.i(_tag, '开始BLE设备关联: $_verifiedDeviceName:$_verifiedDeviceAddress'); |
|
|
|
if (Platform.isIOS) { |
|
|
|
// 调用BLE管理器的关联方法 |
|
|
|
final success = await _bleManager.startDeviceAssociation( |
|
|
|
deviceNamePattern: _verifiedDeviceName!, |
|
|
|
macAddress: _verifiedDeviceAddress!, |
|
|
|
); |
|
|
|
|
|
|
|
// // 调用BLE管理器的关联方法 |
|
|
|
// final success = await _bleManager.startDeviceAssociation( |
|
|
|
// deviceNamePattern: _verifiedDeviceName!, |
|
|
|
// macAddress: _verifiedDeviceAddress!, |
|
|
|
// ); |
|
|
|
|
|
|
|
// if (success) { |
|
|
|
// Logger.i(_tag, 'BLE设备关联成功'); |
|
|
|
// 关联成功后,转到等待BLE连接状态 |
|
|
|
_transition(PairingState.waitingBle); |
|
|
|
// } else { |
|
|
|
// _setError(ErrorType.associationFailed, |
|
|
|
// 'bleDeviceAssociationFailed'.tr); //BLE设备关联失败 |
|
|
|
// } |
|
|
|
if (success) { |
|
|
|
Logger.i(_tag, 'BLE设备关联成功'); |
|
|
|
//关联成功后,转到等待BLE连接状态 |
|
|
|
_transition(PairingState.waitingBle); |
|
|
|
} else { |
|
|
|
_setError(ErrorType.associationFailed, |
|
|
|
'bleDeviceAssociationFailed'.tr); //BLE设备关联失败 |
|
|
|
} |
|
|
|
} else { |
|
|
|
_transition(PairingState.waitingBle); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
Logger.e(_tag, 'BLE设备关联异常: $e'); |
|
|
|
_setError(ErrorType.associationFailed, |
|
|
|
@ -803,7 +807,7 @@ class PairingController extends GetxController with WidgetsBindingObserver { |
|
|
|
} |
|
|
|
} else { |
|
|
|
//未绑定设备 |
|
|
|
_bleManager.clearPairedDevices(); |
|
|
|
_bleManager.clearPairedDevices(); |
|
|
|
Logger.i(_tag, '验证时BLE状态: $currentBleState'); |
|
|
|
if (currentBleState == 2) { |
|
|
|
//已连接 清理 |
|
|
|
|