DIY iBeacon

$ sudo hciconfig
hci1:   Type: Primary  Bus: USB
hci0:   Type: Primary  Bus: UART

$ sudo vi /etc/systemd/system/ibeacon.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now ibeacon
[Unit]
Description=iBeacon Service
Documentation=http://stackoverflow.com/questions/21124993/
Requires=bluetooth.service
After=dbus-org.bluez.service sys-subsystem-bluetooth-devices-hci1.device

[Service]
Type=oneshot
Environment="DEVICE=hci1"
Environment="UUID=88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88"
Environment="MAJOR=00 00"
Environment="MINOR=00 00"
Environment="POWER=C8"
ExecStart=/bin/hciconfig $DEVICE up
ExecStart=/bin/hciconfig $DEVICE noscan
ExecStart=/usr/bin/hcitool -i $DEVICE cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 $UUID $MAJOR $MINOR $POWER 00
ExecStart=/usr/bin/hcitool -i $DEVICE cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
ExecStart=/usr/bin/hcitool -i $DEVICE cmd 0x08 0x000a 01
ExecStop=/bin/hciconfig $DEVICE noleadv
ExecStop=/bin/hciconfig $DEVICE down
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

注意: 本人使用了USB蓝牙适配器(CSR 4.0), 比树莓派自带的Bluetooth芯片稳定.

参考: https://en.wikipedia.org/wiki/IBeacon