我正在尝试使用CoreBluetooth(蓝牙4.0)通过iPhone连接到树莓派。我已经发现了设备并使用以下代码发送了连接请求:
if (peripheral != self.foundPeripheral) {
NSLog(@"Try to connect to %@", peripheral.name);
self.foundPeripheral = peripheral;
[self.centralManager stopScan];
[self.centralManager connectPeripheral:peripheral options:nil];
}
didConnectPeripheral和didFailedToConnectPeripheral都没有被调用。我还确保设置了RPi以使用Bluetooth Low Energy进行广告。
sudo hciconfig hci0 leadv
但是当我使用以下命令检查活动连接时:
hcitool con
目前没有活动连接。我是否遗漏了为树莓派做的一些设置?另外,外围设备上的名称变量为空,这是因为我还没有连接吗?
attrib_server.c
的文件似乎对此起了一定作用。 - Tim Tisdall