Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone IOS核心蓝牙外围设备连接请求_Iphone_Ios_Core Bluetooth - Fatal编程技术网

Iphone IOS核心蓝牙外围设备连接请求

Iphone IOS核心蓝牙外围设备连接请求,iphone,ios,core-bluetooth,Iphone,Ios,Core Bluetooth,我正在使用corebluetooth框架,如果两个BLE都可见,我可以发现并连接设备。现在我遇到了一个问题,我能够发现设备一旦发现由于某种原因外围设备被关闭,现在我正在尝试使用 [centralManager connectPeripheral:activePeripheral options:nil]; 这种方法,但是外设无法连接,所以我需要检查之前 连接是否可用 谢谢您有一种方法: - (void)centralManager:(CBCentralManager *)central did

我正在使用corebluetooth框架,如果两个BLE都可见,我可以发现并连接设备。现在我遇到了一个问题,我能够发现设备一旦发现由于某种原因外围设备被关闭,现在我正在尝试使用

[centralManager connectPeripheral:activePeripheral options:nil];
这种方法,但是外设无法连接,所以我需要检查之前 连接是否可用

谢谢

您有一种方法:

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
如果添加扫描选项,如:

NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:@YES, CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[manager scanForPeripheralsWithServices:nil options:options];
然后,将连续调用上述方法来更新外围设备的状态。然后,您可以观察一段时间内没有调用该方法的外围设备,然后从列表中删除该外围设备


或者,第二种选择是在连接到外围设备之前再次扫描它。

您想要可用蓝牙设备的列表吗?或者你需要检查指定的设备?我有设备清单。有一次我发现我的外围设备正在关闭,我正在尝试连接。