152

我想用一些低功耗蓝牙开发套件创建我自己的 iBeacon。Apple 尚未发布 iBeacon 规范,但是,一些硬件开发人员已经从 AirLocate 示例代码对 iBeacon 进行了逆向工程,并开始销售 iBeacon 开发套件。

那么什么是 iBeacon 蓝牙配置文件?

低功耗蓝牙使用 GATT 进行 LE 配置文件服务发现。所以我认为我们需要知道 Attribute Handle、Attribute Type、Attribute Value,也许还有 iBeacon 属性的 Attribute Permissions。那么对于 UUID 为 E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 的 iBeacon,主要值为 1,次要值为 1,蓝牙 GATT 配置文件服务是什么?

以下是我从 Apple 论坛和文档的讨论中做出的一些假设。

  1. 您只需要查看蓝牙外围设备的配置文件服务 (GATT) 即可知道它是 iBeacon。

  2. 主要和次要密钥在此配置文件服务中的某处进行编码

以下是一些拥有 iBeacon Dev Kits 的公司,它们似乎已经有了这个数字:

希望我们能及时在 Bluetooth.org 上发布如下配置文件:https ://www.bluetooth.org/en-us/specification/adopted-specifications

4

6 回答 6

230

对于具有 ProximityUUID E2C56DB5-DFFB-48D2-B060-D0F5A71096E0、major 0、minor0和 calibrated Tx Power of -59RSSI 的 iBeacon,传输的 BLE 广告数据包如下所示:

d6 be 89 8e 40 24 05 a2 17 6e 3d 71 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 52 ab 8d 38 a5

这个数据包可以分解如下:

d6 be 89 8e # Access address for advertising data (this is always the same fixed value)
40 # Advertising Channel PDU Header byte 0.  Contains: (type = 0), (tx add = 1), (rx add = 0)
24 # Advertising Channel PDU Header byte 1.  Contains:  (length = total bytes of the advertising payload + 6 bytes for the BLE mac address.)
05 a2 17 6e 3d 71 # Bluetooth Mac address (note this is a spoofed address)
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 # Bluetooth advertisement
52 ab 8d 38 a5 # checksum

该数据包的关键部分是蓝牙广告,可以这样分解:

02 # Number of bytes that follow in first AD structure
01 # Flags AD type
1A # Flags value 0x1A = 000011010  
   bit 0 (OFF) LE Limited Discoverable Mode
   bit 1 (ON) LE General Discoverable Mode
   bit 2 (OFF) BR/EDR Not Supported
   bit 3 (ON) Simultaneous LE and BR/EDR to Same Device Capable (controller)
   bit 4 (ON) Simultaneous LE and BR/EDR to Same Device Capable (Host)
1A # Number of bytes that follow in second (and last) AD structure
FF # Manufacturer specific data AD type
4C 00 # Company identifier code (0x004C == Apple)
02 # Byte 0 of iBeacon advertisement indicator
15 # Byte 1 of iBeacon advertisement indicator
e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 # iBeacon proximity uuid
00 00 # major 
00 00 # minor 
c5 # The 2's complement of the calibrated Tx Power

任何可以配置为发送特定广告的蓝牙 LE 设备都可以生成上述数据包。我已经使用 Bluez 配置了一台 Linux 计算机来发送此广告,并且运行 Apple 的 AirLocate 测试代码的 iOS7 设备将其作为具有上述指定字段的 iBeacon 拾取。请参阅:将 BlueZ Stack 用作外设(广告商)

博客包含有关逆向工程过程的完整详细信息。

于 2013-09-26T23:56:26.457 回答
47

它似乎基于广告数据,特别是制造商数据:

4C00 02 15 585CDE931B0142CC9A1325009BEDC65E 0000 0000 C5

<company identifier (2 bytes)> <type (1 byte)> <data length (1 byte)>
    <uuid (16 bytes)> <major (2 bytes)> <minor (2 bytes)> <RSSI @ 1m>
  • Apple 公司标识符 (Little Endian), 0x004c
  • 数据类型,0x02 => iBeacon
  • 数据长度,0x15 = 21
  • uuid:585CDE931B0142CC9A1325009BEDC65E
  • 专业:0000
  • 未成年人:0000
  • 1 米处测得的功率:0xc5 = -59

我有这个node.js 脚本在 Linux 上使用示例 AirLocate 应用程序示例。

于 2013-09-26T11:00:21.613 回答
20

只是为了调和 Sandeepmistry 的答案和 davidgyoung 的答案之间的区别:

02 01 1a 1a ff 4C 00

是广告数据格式规范的一部分 [1]

  02 # length of following AD structure
  01 # <<Flags>> AD Structure [2]
  1a # read as b00011010. 
     # In this case, LE General Discoverable,
     # and simultaneous BR/EDR but this may vary by device!

  1a # length of following AD structure
  FF # Manufacturer specific data [3]
4C00 # Apple Inc [4]
0215 # ?? some 2-byte header

AD 中缺少一个服务 [5] 定义。我认为 iBeacon 协议本身与 GATT 和标准服务发现无关。如果你下载 RedBearLab 的 iBeacon 程序,你会发现他们碰巧使用 GATT 来配置广告参数,但这似乎是特定于他们的实现,而不是规范的一部分。AirLocate 程序似乎没有使用 GATT 进行配置,例如,根据我尝试过的 LightBlue 或其他类似程序。

参考:

  1. 核心蓝牙规范 v4,第 3 卷,C 部分,11
  2. 第 3 卷,C 部分,18.1
  3. 第 3 卷,C 部分,18.11
  4. https://www.bluetooth.org/en-us/specification/assigned-numbers/company-identifiers
  5. 第 3 卷,C 部分,18.2
于 2013-10-04T07:20:02.683 回答
6

如果您问这个问题的原因是因为您想使用 Core Bluetooth 作为 iBeacon 进行宣传,而不是使用标准 API,您可以通过宣传 NSDictionary 轻松做到这一点,例如:

{
    kCBAdvDataAppleBeaconKey = <a7c4c5fa a8dd4ba1 b9a8a240 584f02d3 00040fa0 c5>;
}

有关更多信息,请参阅此答案

于 2014-01-05T10:01:52.113 回答
4

这很简单,它只是宣传一个包含几个符合Apple iBeacon 标准的字符的字符串。您可以参考链接 http://glimwormbeacons.com/learn/what-makes-an-ibeacon-an-ibeacon/

于 2015-06-30T18:10:05.223 回答
0

iBeacon Profile 包含 31 个字节,其中包括以下内容

  1. 前缀 - 9 字节 - 包括广告数据和制造商数据
  2. UUID - 16 字节
  3. 主要 - 2 字节
  4. 次要 - 2 字节
  5. TxPower - 1 字节

在此处输入图像描述

于 2018-04-05T12:21:39.293 回答