iBeacon on Raspberry Pi

树莓派(3B)上的蓝牙, 除了可以连接音响/键盘/游戏手柄外, 也可作为iBeacon基站.

Server Setup

$ sudo hciconfig hci0 up
$ sudo hciconfig hci0 leadv 3
$ sudo hciconfig hci0 noscanc

$ hciconfig
hci0:    Type: BR/EDR  Bus: UART  
    BD Address: B8:27:EB:31:F6:8A  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING
    RX bytes:793 acl:0 sco:0 events:51 errors:0
    TX bytes:1649 acl:0 sco:0 commands:49 errors:0

$ sudo 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

Client Setup

Result

  • RSSI: 信号强度
  • TX: 参考信号(1m)
  • Distance: 距离