问题描述
我正在尝试使用CoreBluetooth(蓝牙4.0)通过iPhone连接到Raspberry Pi.我发现了该设备,并使用以下代码发送了连接请求:
I am trying to connect to a Raspberry Pi via iPhone using CoreBluetooth (bluetooth 4.0). I have discovered the device and send out a connection request using this code:
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设置为使用
Neither the didConnectPeripheral or didFailedToConnectPeripheral are called. I also made sure to set the RPi to advertise bluetooth low energy using
sudo hciconfig hci0 leadv
但是当我使用
hcitool con
没有活动的连接.我是否缺少为RPi设置的设置?外围设备上的name变量也是空白的,是因为我还没有连接吗?
there are no active connections. Am I missing some set up for the RPi? Also the name variable on the peripheral is blank, is that because I have not connected yet?
推荐答案
尝试 bleno ,可用于在OS X和Linux上创建BLE外设的node.js库.它在运行Raspbian的Raspberry Pi上运行良好.
Try out bleno, it's a node.js library that can be used to create a BLE peripheral on both OS X and Linux. It works well on my Raspberry Pi running Raspbian.
这篇关于Raspberry Pi蓝牙4.0连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!