David Lilly
David Lilly

Reputation: 13

iBeacon Broadcast Interval with Raspberry Pi

I have an iBeacon broadcasting every ~1280 ms from my Raspberry Pi, but I need it to broadcast every ~100ms how do I configure this?

How I'm set up:

I followed this guide: http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/

I have a Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

My config string:

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

On my phone I see my iBeacon, the UUID is correct, the Major and Minor versions are correct. The problem I'm having is the broadcast rate.

Can I change this from ~1.2 seconds to ~100 ms?

Update 1: I'm still getting errors.

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 

Update 2: I found a way to make it work:

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

I think the key was the noscan part. I think if scan was on I couldn't change the advertisement frequency.

An additional resource I found useful: https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=229737 Specifically Volume 2, Part E, Section 7.8 This gave me the actual description of the commands I was sending, instead of copy and paste programming.

Upvotes: 1

Views: 2006

Answers (1)

davidgyoung
davidgyoung

Reputation: 64941

You can increase the advertising rate to 10 Hz like this:

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

See here for more info:

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

Upvotes: 2

Related Questions