lo2ndii
lo2ndii

Reputation: 75

iBeacon Dynamic Minor Value

I am using a Raspberry Pi as an iBeacon by creating a LaunchService that runs on startup executing the following (using BlueZ):

sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0006 40 [...] 00
sudo hcitool -i hci0 cmd 0x08 0x000A 01
sudo hcitool -i hci0 cmd 0x08 0x0008 1E [...] 02 C0 00 00 00 00 C5 00

So far this has worked beautifully. The service runs and as long as the Pi is powered, the iBeacon is advertised.

Now I would like to send some Information with the advertising data. I have a brightness sensor wired up to the Pi that simply returns true if a certain threshold of brightness has been exceeded.

My idea is to use the Minor identifier and use 1 to represent "it is bright" and 0to represent "it is dark". My app can then interpret this without having to poll the Pi via a network request what the current sensor status is.

But since I set the advertisement package statically, I won't be able to use this approach going forward I believe.

I have no idea how else to do this however, so I was hoping someone might have some insight and could point me in the right direction.

Thanks for your time!

Upvotes: 0

Views: 54

Answers (1)

davidgyoung
davidgyoung

Reputation: 64916

Easy. You can simply re-issue those commands, specifically the last one:

sudo hcitool -i hci0 cmd 0x08 0x0008 1E [...] 02 C0 00 00 00 00 C5 00

Just change the last byte before the C5 above to be 01 if you want to send out a minor of 1, and change it back to 00 if you want to send out a minor of 0.

Upvotes: 1

Related Questions