什么是iBeacon蓝牙配置文件

Pau*_*III 149 reverse-engineering bluetooth ios bluetooth-lowenergy ibeacon

我想用一些蓝牙低能量开发套件创建我自己的iBeacon.Apple还没有发布iBeacons规范,但是一些硬件开发商已经反向使用AirLocate示例代码设计iBeacon并开始销售iBeacon开发套件.

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

Bluetooth Low Energy使用GATT进行LE配置文件服务发现.所以我认为我们需要知道属性句柄,属性类型,属性值,以及iBeacon属性的属性权限.那么,对于UUID为E2C56DB5-DFFB-48D2-B060-D0F5A71096E0的iBeacon,主要值为1,次要值为1,蓝牙GATT配置文件服务是什么?

这是我在Apple论坛和文档讨论中做出的一些假设.

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

  2. Major和Minor键在此配置文件服务中的某处编码

有些公司使用iBeacon Dev Kits似乎已经有了这个数字:

希望我们能及时在Bluetooth.org上发布这样的个人资料:https://www.bluetooth.org/en-us/specification/adopted-specifications

dav*_*ung 223

对于具有ProximityUUID E2C56DB5-DFFB-48D2-B060-D0F5A71096E0,主要0,次要0和校准的-59RSSI Tx功率的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
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

可以配置为发送特定广告的任何蓝牙LE设备都可以生成上述分组.我已经使用Bluez配置了一台Linux计算机来发送这个广告,运行Apple的AirLocate测试代码的iOS7设备将其作为带有上述字段的iBeacon.请参阅:使用BlueZ堆栈作为外围设备(广告商)

博客提供有关逆向工程过程的完整详细信息.


san*_*try 45

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

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>
Run Code Online (Sandbox Code Playgroud)
  • Apple公司标识符(Little Endian),0x004c
  • 数据类型,0x02 => iBeacon
  • 数据长度,0x15 = 21
  • uuid:585CDE931B0142CC9A1325009BEDC65E
  • 专业:0000
  • 未成年人:0000
  • 测量功率为1米:0xc5 = -59

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


sla*_*ppy 20

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

02 01 1a 1a ff 4C 00
Run Code Online (Sandbox Code Playgroud)

是广告数据格式规范的一部分[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
Run Code Online (Sandbox Code Playgroud)

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

参考文献:

  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


Sen*_*ful 6

如果您提出这个问题的原因是因为您想使用Core Bluetooth作为iBeacon进行广告而不是使用标准API,您可以通过宣传NSDictionary来轻松实现,例如:

{
    kCBAdvDataAppleBeaconKey = <a7c4c5fa a8dd4ba1 b9a8a240 584f02d3 00040fa0 c5>;
}
Run Code Online (Sandbox Code Playgroud)

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