与Raspberry Pi的iBeacon广播时间间隔

时间:2015-08-22 07:12:25

标签: bluetooth raspberry-pi bluetooth-lowenergy ibeacon

我的Raspberry Pi每隔~1280毫秒播放一次iBeacon广播,但我需要每隔~100ms广播一次,如何配置?

我如何设置:

我遵循了这个指南: http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/

我有一个Cambridge Silicon Radio,Ltd Bluetooth Dongle(HCI模式)

我的配置字符串:

hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00

在我的手机上,我看到我的iBeacon,UUID是正确的,主要和次要版本是正确的。我遇到的问题是广播费率。

我可以将此值从~1.2秒更改为~100 ms吗?

更新1: 我仍然遇到错误。

pi@raspberrypi ~ $ sudo hciconfig hci0 up
pi@raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 44
  1E 02 01 1A 1A FF 4C 00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60 
  D0 F5 A7 10 96 E0 00 00 00 00 C5 00 00 00 00 00 00 00 00 00 
  00 00 00 00 
> HCI Event: 0x0e plen 4
  01 08 20 12 
pi@raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
< HCI Command: ogf 0x08, ocf 0x0006, plen 15
  A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00 
> HCI Event: 0x0e plen 4
  01 06 20 0C 
pi@raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x000a 01
< HCI Command: ogf 0x08, ocf 0x000a, plen 1
  01 
> HCI Event: 0x0e plen 4
  01 0A 20 0C 

更新2: 我找到了一种让它起作用的方法:

hciconfig hci0 down
hciconfig hci0 up
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00
hcitool -i hci0 cmd 0x08 0x0006 20 00 A0 00 00 00 00 00 00 00 00 00 00 07 00
hcitool -i hci0 cmd 0x08 0x000A 01
hciconfig hci0 noscan

我认为关键是noscan部分。我认为如果扫描开启,我无法改变广告频率。

我觉得有用的其他资源: https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=229737 特别是第2卷,E部分,第7.8节。这给了我发送命令的实际描述,而不是复制和粘贴编程。

1 个答案:

答案 0 :(得分:1)

您可以将广告费率提高到10 Hz,如下所示:

sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
sudo hcitool -i hci0 cmd 0x08 0x000a 01

有关详细信息,请参阅此处:

Is there a way to increase BLE advertisement frequency in BlueZ?