update: 2016/04/01
reference:
1. Raspberry Pi應用 - Bluetooth 4.0 使用 iBeacon
2. Overview | piBeacon - DIY Beacon with a Raspberry Pi
3. Raspberry Pi 3 as an Eddystone URL beacon
A. Install Required Libraries
$ sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
-----------------------------------------------------------------------------------------------
B. Download Bluez
$ sudo mkdir bluez
$ cd bluez
$ sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.38.tar.xz
-----------------------------------------------------------------------------------------------
C. Unzip and Compile Bluez
$ sudo unxz bluez-5.38.tar.xz
$ sudo tar xvf bluez-5.38.tar
$ cd bluez-5.38
$ sudo ./configure --disable-systemd
$ sudo make
$ sudo make install
-----------------------------------------------------------------------------------------------
D. Check for your USB Module
$ cd /home/pi/bluez/bluez-5.38
$ tools/hciconfig
hci0: Type: BR/EDR Bus: USB
BD Address: 00:1A:7D:DA:71:13 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING
RX bytes:652 acl:0 sco:0 events:43 errors:0
TX bytes:1533 acl:0 sco:0 commands:43 errors:0
-----------------------------------------------------------------------------------------------
E. Enable the USB Device
$ sudo tools/hciconfig hci0 up
$ sudo tools/hciconfig hci0 leadv 3
LE set advertise enable on hci0 returned status 12
$ sudo tools/hciconfig hci0 noscan
-----------------------------------------------------------------------------------------------
F. Enter the Beacon Advertising Data
$ sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 32
1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F
17 D1 AD 07 A9 61 00 00 00 00 C8 00
> HCI Event: 0x0e plen 4
01 08 20 00
-----------------------------------------------------------------------------------------------
G. 測試軟體
1. Mac: Beacon Scan
2. iOS: Locate Beacon
3. Android: Locate Beacon
-----------------------------------------------------------------------------------------------
H. 簡易開機自動啟動
$ sudo nano /home/pi/iBeacon.sh
#!/bin/bash
sleep 5
cd /home/pi/bluez/bluez-5.38/
tools/hciconfig hci0 leadv 3
tools/hciconfig hci0 noscan
tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
$ sudo crontab -e
....
@reboot /home/pi/iBeacon.sh
-----------------------------------------------------------------------------------------------
I. 測試結果:(iOS)