我想连接到蓝牙BTLE设备。我发现外设没问题。
但是,当我试图连接到外围设备时,我收到了以下警告。
2013-04-05 22:10:36.110 CoreBluetoothWARNING 7DA9E322-D710-081B-4A9D-526DE546B13C,名称=“查找我的汽车智能车”,IsConnected = NO>连接时正在取消分配
此外,没有一种相关的委托方法被称为:
didConnectPeripheral:
didFailToConnectPeripheral:我挣扎了好几个小时..。请帮帮忙。
发布于 2013-04-07 13:31:14
简短的回答:你需要保留外围。
长说明:核心蓝牙不知道你是否对这个外围设备感兴趣,当它被发现。连接到它是不够的,你需要保留它。
将属性添加到您要执行的所有操作的类中:
@property (strong) CBPeripheral *connectingPeripheral;然后,当设备被发现时,在您从didDiscoverPeripheral返回之前,将外围设备分配给此属性。
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
DDLogVerbose(@"Discovered peripheral: %@ advertisement %@ RSSI: %@", [peripheral description], [advertisementData description], [RSSI description]);
[central connectPeripheral:peripheral options:nil];
self.connectingPeripheral = peripheral;
}https://stackoverflow.com/questions/15846663
复制相似问题