Browse Source

修复逻辑,修复版定

newdev_shunjiawei
fdp 1 year ago
parent
commit
a85a7f7035
  1. 28
      lib/modules/pairing/controllers/pairing_controller.dart
  2. 2
      local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift

28
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字节的授权码

2
local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift

@ -235,7 +235,7 @@ private var cmdReplyType: UInt8 = 0
// ])
let serviceUUIDs = [BleConst.SERVICE_UUID, BleConst.SERVICE_UUID1]
manager.scanForPeripherals(withServices: serviceUUIDs, options: [
manager.scanForPeripherals(withServices: nil, options: [
CBCentralManagerScanOptionAllowDuplicatesKey: true // 允许重复以获取更新的广播数据
])
os_log("🔍 开始扫描所有BLE设备(无过滤),超时时间: %.1f秒", log: logger, type: .info, timeout)

Loading…
Cancel
Save