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 3ce8a26aa..87c242ef8 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 @@ -290,7 +290,7 @@ private var cmdReplyType: UInt8 = 0 // 完整UUID cbuuid = CBUUID(string: uuidStr) } else { - os_log("⚠️ 无效的UUID格式: %{public}@", log: logger, type: .warning, uuidStr) + os_log("⚠️ 无效的UUID格式: %{public}@", log: logger, type: .default, uuidStr) continue } serviceUUIDs.append(cbuuid) @@ -300,11 +300,13 @@ private var cmdReplyType: UInt8 = 0 } } - // 开始扫描,使用构建的服务UUID数组进行过滤 - manager.scanForPeripherals(withServices: serviceUUIDs.isEmpty ? nil : serviceUUIDs, options: [ + // // 开始扫描,使用构建的服务UUID数组进行过滤 + // manager.scanForPeripherals(withServices: serviceUUIDs.isEmpty ? nil : serviceUUIDs, options: [ + // CBCentralManagerScanOptionAllowDuplicatesKey: true // 允许重复以获取更新的广播数据 + // ]) + manager.scanForPeripherals(withServices: nil , options: [ CBCentralManagerScanOptionAllowDuplicatesKey: true // 允许重复以获取更新的广播数据 ]) - let filterInfo = serviceUUIDs.isEmpty ? "无过滤" : "过滤器数量: \(serviceUUIDs.count)" os_log("🔍 开始扫描BLE设备(%{public}@),超时时间: %.1f秒", log: logger, type: .info, filterInfo, timeout) diff --git a/local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift b/local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift index dd9d07f14..eb7fc5215 100644 --- a/local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift +++ b/local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift @@ -112,9 +112,10 @@ public class SwiftBleServicePlugin: NSObject, FlutterPlugin { case "startScan": let arguments = call.arguments as? [String: Any] let timeout = (arguments?["timeout"] as? Double) ?? 15.0 + let uuids = (arguments?["uuids"] as? [String]) ?? [] os_log("🔍 开始传统BLE扫描,超时: %.1f秒", log: logger, type: .info, timeout) - BleService.shared.startScan(timeout: timeout) + BleService.shared.startScan(timeout: timeout, uuids: uuids) result(true) case "stopScan":