From 693571cda8a1f8f5dcbaa47f9c9d44652c545255 Mon Sep 17 00:00:00 2001 From: fdp <1286779656@qq.com> Date: Wed, 23 Jul 2025 20:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=88=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/pairing_controller.dart | 28 +++++++++++++------ .../Sources/ble_service/BleService.swift | 7 ++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/modules/pairing/controllers/pairing_controller.dart b/lib/modules/pairing/controllers/pairing_controller.dart index af7e399f8..5992d98cf 100644 --- a/lib/modules/pairing/controllers/pairing_controller.dart +++ b/lib/modules/pairing/controllers/pairing_controller.dart @@ -660,14 +660,26 @@ class PairingController extends GetxController { String? uuids = deviceInfo["id"]; _verifiedDeviceAddress = uuids; print('找到匹配设备,获取到 uuids: $uuids'); - // 检查是否已经绑定 - // if (User.instance.earphonelicense != "" && - // User.instance.earphonemac == device.address) { - // // 已经绑定 - // return 10; - // } else { - return 1; - // } + //检查是否已经绑定 + final existingDevice = User.instance.devices.firstWhere( + (d) => + d.devicetype == 2 && + d.license != "" && + d.devicemac == device.address, + orElse: () => UserDevice( + id: -1, + uid: '', + devicetype: -1, + devicename: '', + devicemac: '', + license: ''), + ); + if (existingDevice.id != -1) { + // 已经绑定 + return 10; + } else { + return 1; + } } } else if (Platform.isAndroid) { // Android设备,提取15-24字节的授权码 diff --git a/local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift b/local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift index c54bacde2..6647a5e4a 100644 --- a/local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift +++ b/local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift @@ -229,7 +229,12 @@ private var cmdReplyType: UInt8 = 0 isScanning = true - // 移除服务UUID过滤,扫描所有设备 + // // 移除服务UUID过滤,扫描所有设备 + // manager.scanForPeripherals(withServices: nil, options: [ + // CBCentralManagerScanOptionAllowDuplicatesKey: true // 允许重复以获取更新的广播数据 + // ]) + let serviceUUIDs = [BleConst.SERVICE_UUID, BleConst.SERVICE_UUID1] + manager.scanForPeripherals(withServices: nil, options: [ CBCentralManagerScanOptionAllowDuplicatesKey: true // 允许重复以获取更新的广播数据 ])