如何自行架设一个 iOS 7 设备可用的 iBeacons 广播基站?

来源:互联网 发布:好看的网络自制剧古装 编辑:程序博客网 时间:2024/05/22 14:23
如果不想弄脏自己的手,Radius 上面有一个即买即用的预组装套装(包括配置)。只卖一百美元。套装包含下面这些组建:

  • Raspberry Pi PC
  • Bluetooth LE Module
  • 8 GB SD Card, pre-loaded with iBeacon software that's fully compatible with Apple's iBeacon SDK
  • Full instructions for customizing the iBeacon identifiers

如果自己手上都有上面的这些东西,那么可以参照 Radius 提供的完整指引自己拼装配置:

  1. 必要组建:一块 Raspberry Pi 开发板;4GB 以上的 SD 卡;一个支持低功耗蓝牙的蓝牙适配器;一个标准的 5V 电压输出 miro-USB 接口充电器。
  2. 一些小工具:一个 USB 键盘和一个 USB 鼠标;一个支持 HDMI 输入的显示器;一根 HDMI 数据线;一根用于接入互联网的网线;一个支持 AirLocate/iBeaconLocate 的 Android 或者 iOS 设备。

组装步骤:

  1. 参照这个指引,接上鼠标键盘显示器和网线来配置 Raspberry Pi,系统安装过程中选择 "raspbian" 模式;
  2. 到这一步可以不需要鼠标,接上蓝牙适配器;
  3. 登入系统,用户名: pi, 密码: raspberry
  4. 确认可以连接网络:
    $ ping www.google.comPING www.google.com (74.125.228.116): 56 data bytes64 bytes from 74.125.228.116: icmp_seq=0 ttl=55 time=34.267 ms64 bytes from 74.125.228.116: icmp_seq=1 ttl=55 time=30.908 ms
    如果看到上面的结果,说明设备处于联网状态
  5. 安装 Build Packages:
    $ sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
  6. 下载并解压必要的 BlueZ 包:
    $ sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.8.tar.xz$ sudo unxz bluez-5.8.tar.xz$ sudo tar xvf bluez-5.8.tar$ cd bluez-5.8
  7. 配置和构造 BlueZ:
    $ sudo ./configure -disable-systemd$ sudo make$ sudo make install
  8. 配置蓝牙适配器:
    要确认蓝牙适配器已经查到 Raspberry Pi 上面了哦,然后再输入命令行:
    $ hciconfig
    这样就能看到蓝牙适配器的一些基本信息,大概是类似这样的:
    hci0:   Type: BR/EDR  Bus: USB         BD Address: 00:01:0A:39:D4:06  ACL MTU: 1021:8  SCO MTU: 64:1         DOWN         RX bytes:1000 acl:0 sco:0 events:47 errors:0         TX bytes:1072 acl:0 sco:0 commands:47 errors:0
    注意看到上面我下划线加注的 "DOWN" 字样,说明设备处于未工作状态,我们通过输入下面命令行启动它:
    $ sudo hciconfig hci0 up
    然后就会看到类似这样的结果:
    $ hciconfighci0:   Type: BR/EDR  Bus: USB         BD Address: 00:02:72:3F:4D:60  ACL MTU: 1021:8  SCO MTU: 64:1         UP RUNNING         RX bytes:1000 acl:0 sco:0 events:47 errors:0         TX bytes:1072 acl:0 sco:0 commands:47 errors:0
    接着执行下面这段命令,是一段测试广播:
    $ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00

    上面是一个 Profile UUID 为 E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 的全零广播
  9. 到这一步,其实广播内容实际并没有在广播,还需要一个激活的命令行:
    sudo hciconfig hci0 leadv 0
    现在,就可以用支持接收广播的 Android 或者 iOS 设备测试最终结果了。关闭广播的命令行是:
    sudo hciconfig hci0 leadv 0

大概就是这样了。上面的内容转述自 Radius Networks 提供的指引。更进阶的功能,还请大家查看原文。(我找个时间实际操作一番再上来更新)


转自 知乎

http://developer.radiusnetworks.com/2013/10/09/how-to-make-an-ibeacon-out-of-a-raspberry-pi.html

0 0
原创粉丝点击