0

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!

lo2ndii
  • 75
  • 6

1 Answers1

1

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.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • So I would write a script that periodically checks the sensor value and reissues the command based on that? – lo2ndii Mar 18 '17 at 08:21
  • Yes exactly. It is unclear how you read the sensor, but if you can post an example I can show a shell script that dynamically changes the beacon transmission value. – davidgyoung Mar 18 '17 at 12:28
  • Thanks! I worked it out using crontab and wiringPi! :) – lo2ndii Mar 18 '17 at 12:29