树莓派蓝牙 4.0 连接 [英] Raspberry Pi Bluetooth 4.0 Connection
问题描述
我正在尝试使用 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,这是一个node.js 库,可用于在 OS X 和 Linux 上创建 BLE 外设.它在运行 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.
这篇关于树莓派蓝牙 4.0 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!