所以当谈到蓝牙时,我是一个新手,我正在尝试让它扫描设备,如果我尝试使用这个来扫描所有设备:
self.centralManager.scanForPeripherals(withServices: nil, options: nil);
它找到了几个设备,我打印出uuidStrings并获得了几个设备uuids但是当我尝试搜索那些特定的uuids时它找不到任何东西,这就是我正在使用的代码:
private var uuidArray = ["8B2F2570-9E3B-1FB6-C76E-9258526B662B",
"4A29E654-F59F-53AD-D7F6-B435B8BBAB78",
"48F038D0-246C-4D62-A025-1D822CAFB93A",
"D8E13B7A-BB89-45C2-8747-BAE1D94AE9E0",
"558CF744-2C4F-439F-AD7F-E2212938123B",
"967B98AC-FFE7-45EC-8D25-0276FBD57FC8"];
func scanForPeripherals (timeout: Double) -> Bool {
if (self.centralManager.state != .poweredOn) {
print ("[BLE] Central Manager is not powered on");
return false;
}
print ("[BLE] Start Scan");
Timer.scheduledTimer(timeInterval: timeout, target: self, selector: #selector(stopScan), userInfo: nil, repeats: false)
var services: [CBUUID] = [];
for uuid in uuidArray {
let cbuuid = CBUUID(string: uuid);
services.append(cbuuid);
}
self.centralManager.scanForPeripherals(withServices: services, options: nil);
return true;
}
我在这里错过了什么吗?有谁知道如何找到特定的设备?