ios 什么是 iBeacon 蓝牙配置文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18906988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the iBeacon Bluetooth Profile
提问by PaulWoodIII
I'd like to create my own iBeacon with some bluetooth low energy dev kits. Apple has yet to release a specification for iBeacons, however a few hardware developers have reverse Engineered the iBeacon from the AirLocate Sample code and started selling iBeacon dev kits.
我想用一些蓝牙低功耗开发套件创建我自己的 iBeacon。Apple 还没有发布 iBeacon 的规范,但是一些硬件开发人员已经从 AirLocate 示例代码对 iBeacon 进行了逆向工程,并开始销售 iBeacon 开发套件。
So what is the iBeacon Bluetooth Profile?
那么什么是 iBeacon 蓝牙配置文件?
Bluetooth Low Energy uses GATT for LE profile service discovery. So I think we need to know the Attribute Handle, Attribute Type, Attribute Value, and maybe the Attribute Permissions of the iBeacon attribute. So for an iBeacon with a UUID of E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 a major value of 1 and a minor value of 1 what would the Bluetooth GATT profile service be?
低功耗蓝牙使用 GATT 进行 LE 配置文件服务发现。所以我认为我们需要知道 iBeacon 属性的属性句柄、属性类型、属性值,也许还有属性权限。因此,对于 UUID 为 E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 的 iBeacon,主要值 1 和次要值 1 的蓝牙 GATT 配置文件服务是什么?
Heres some assumptions I've made from the discussion on Apple's forums and through the docs.
下面是我从 Apple 论坛上的讨论和文档中做出的一些假设。
You only need to see the profile service (GATT) of a Bluetooth peripheral to know it is an iBeacon.
The Major and Minor keys are encoded somewhere in this profile service
您只需要查看蓝牙外设的配置文件服务 (GATT) 即可知道它是 iBeacon。
Major 和 Minor 键在此配置文件服务中的某处编码
Heres some companies with iBeacon Dev Kits that seem to have this figure out already:
下面是一些拥有 iBeacon Dev Kits 的公司,它们似乎已经有了这个数字:
Hopefully in time we will have a profile posted on Bluetooth.org like these: https://www.bluetooth.org/en-us/specification/adopted-specifications
希望及时我们将在 Bluetooth.org 上发布这样的配置文件:https: //www.bluetooth.org/en-us/specification/adopted-specifications
回答by davidgyoung
For an iBeacon with ProximityUUID E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
, major 0
, minor 0
, and calibrated Tx Power of -59
RSSI, the transmitted BLE advertisement packet looks like this:
对于具有 ProximityUUID E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
、主要0
、次要0
和-59
RSSI校准 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 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
This packet can be broken down as follows:
这个数据包可以分解如下:
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
The key part of that packet is the Bluetooth Advertisement, which can be broken down like this:
该数据包的关键部分是蓝牙广告,可以这样分解:
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
Any Bluetooth LE device that can be configured to send a specific advertisement can generate the above packet. I have configured a Linux computer using Bluez to send this advertisement, and iOS7 devices running Apple's AirLocate test code pick it up as an iBeacon with the fields specified above. See: Use BlueZ Stack As A Peripheral (Advertiser)
任何可以配置为发送特定广告的蓝牙 LE 设备都可以生成上述数据包。我已经使用 Bluez 配置了一台 Linux 计算机来发送此广告,并且运行 Apple 的 AirLocate 测试代码的 iOS7 设备将其作为具有上述指定字段的 iBeacon 接收。请参阅:使用 BlueZ Stack 作为外围设备(广告商)
This bloghas full details about the reverse engineering process.
这个博客有关于逆向工程过程的完整细节。
回答by sandeepmistry
It seems to based on advertisement data, particularly the manufacturer data:
它似乎基于广告数据,尤其是制造商数据:
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 Company Identifier (Little Endian), 0x004c
- data type, 0x02 => iBeacon
- data length, 0x15 = 21
- uuid: 585CDE931B0142CC9A1325009BEDC65E
- major: 0000
- minor: 0000
- meaured power at 1 meter: 0xc5 = -59
- Apple 公司标识符(Little Endian),0x004c
- 数据类型,0x02 => iBeacon
- 数据长度,0x15 = 21
- uuid:585CDE931B0142CC9A1325009BEDC65E
- 专业:0000
- 未成年人:0000
- 1 米处的测量功率:0xc5 = -59
I have this node.js scriptworking on Linux with the sample AirLocate app example.
我有这个node.js 脚本在 Linux 上使用示例 AirLocate 应用程序示例。
回答by slackhappy
Just to reconcile the difference between sandeepmistry's answer and davidgyoung's answer:
只是为了调和 sandeepmistry 的答案和 davidgyoung 的答案之间的差异:
02 01 1a 1a ff 4C 00
Is part of the advertising data format specification [1]
是广告数据格式规范的一部分 [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
Missing from the AD is a Service [5] definition. I think the iBeacon protocol itself has no relationship to the GATT and standard service discovery. If you download RedBearLab's iBeacon program, you'll see that they happen to use the GATT for configuring the advertisement parameters, but this seems to be specific to their implementation, and not part of the spec. The AirLocate program doesn't seem to use the GATT for configuration, for instance, according to LightBlue and or other similar programs I tried.
AD 中缺少服务 [5] 定义。我认为 iBeacon 协议本身与 GATT 和标准服务发现没有关系。如果您下载 RedBearLab 的 iBeacon 程序,您会看到它们碰巧使用 GATT 来配置广告参数,但这似乎是特定于它们的实现,而不是规范的一部分。AirLocate 程序似乎没有使用 GATT 进行配置,例如,根据 LightBlue 和我尝试过的其他类似程序。
References:
参考:
- Core Bluetooth Spec v4, Vol 3, Part C, 11
- Vol 3, Part C, 18.1
- Vol 3, Part C, 18.11
- https://www.bluetooth.org/en-us/specification/assigned-numbers/company-identifiers
- Vol 3, Part C, 18.2
- 核心蓝牙规范 v4,第 3 卷,C 部分,11
- 第 3 卷,C 部分,18.1
- 第 3 卷,C 部分,18.11
- https://www.bluetooth.org/en-us/specification/assigned-numbers/company-identifiers
- 第 3 卷,C 部分,18.2
回答by Senseful
If the reason you ask this question is because you want to use Core Bluetooth to advertise as an iBeaconrather than using the standard API, you can easily do so by advertising an NSDictionary such as:
如果您问这个问题的原因是因为您想使用 Core Bluetooth 作为 iBeacon 进行宣传而不是使用标准 API,您可以通过宣传 NSDictionary 轻松实现,例如:
{
kCBAdvDataAppleBeaconKey = <a7c4c5fa a8dd4ba1 b9a8a240 584f02d3 00040fa0 c5>;
}
See this answerfor more information.
有关更多信息,请参阅此答案。
回答by Amit Shelgaonkar
It's very simple, it just advertises a string which contains a few characters conforming to Apple's iBeacon standard. you can refer the Link http://glimwormbeacons.com/learn/what-makes-an-ibeacon-an-ibeacon/
它非常简单,它只是宣传一个字符串,其中包含符合 Apple 的 iBeacon 标准的几个字符。你可以参考链接 http://glimwormbeacons.com/learn/what-makes-an-ibeacon-an-ibeacon/