了解 iBeacon 数据:功率字段和其他字节 [英] Understanding iBeacon data : the power field and other bytes

查看:18
本文介绍了了解 iBeacon 数据:功率字段和其他字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是蓝牙系统的新手,我正在尝试了解用于新 Apple 技术的数据:iBeacon.

I am new to the Bluetooth system and I am trying to understand the data used for the new Apple's technology : iBeacon.

已经有一些很好的答案解释了它是如何工作的,我一直在阅读我能找到的所有内容(尤其是蓝牙规范).尽管如此,我还是遗漏了一些要点,我将首先举个例子:(我正在使用设置广告数据命令,它在这里遗漏了 OGF 之前的 hcitool cmd)

There is already some nice answers which explain how it works and I have been reading everything I could find (especially the Bluetooth Specification). Still, I am missing some points and I will go for an example first : (I am using the Set Advertising Data Command, it misses here the hcitool cmd before the OGF)

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

我会在这里列出我不明白或找不到的信息.

I will list here what I didn't understand or find information about.

  1. 是否有任何关于 OGF 的信息(这里是 0x08)? 我知道它代表 OpCode 组字段,但与 OGF 后面的 OCF 不同,我什么也没找到.
  2. 02 01 1A 1A 字节行代表什么? 我知道第一个字节 1E 表示其余数据,在该行之后,从 FF 开始,您将获得制造商特定的数据.但我找不到关于这 4 个字节的任何信息.
  3. 功率字节是如何工作的?这里是C5.我知道我得到的是测距 iBeacon 时的 dBm 值(例如在我的 iPhone 上).而且我知道值越高(在那个功率字节上),功率就越高,这意味着更高的准确性,但也会消耗更多的能量.但是你如何使用那个字节?您可以设置的最小值和最大值是多少?或者那里有什么公式?对于字节上的设定值,您是否获得了设定的 dBm 值(距 iBeacon 一米处)?
  1. Is there any information anywhere about the OGF (here it is 0x08)? I know it stands for OpCode Group Field, but contratry to the OCF which follows the OGF, I didn't find anything.
  2. What does the 02 01 1A 1A bytes line stand for? I know that the first byte, 1E, tells the length of the rest of the data and after that line, starting with FF, you get the manufacturer specific data. But I couldn't find anything about those 4 bytes.
  3. How does the power byte work? Here it is C5. I know that what I get is the dBm value when ranging my iBeacon (on my iPhone for instance). And I know that the higher the value (on that power byte), the higher the power which means more accuracy but also more energy consumption. But how do you use that byte? What are the min and max values you can set? Or is there any kind of formula there? Do you get a set dBm value (at one meter from your iBeacon) for a set value on the byte?

谢谢.

推荐答案

前两个问题的答案可以在巨大的 蓝牙 4.0 核心规范.

Answers to the first two questions can be found in the gigantic Bluetooth 4.0 Core spec.

  1. 0x08 的 OGF 为 LE 控制器分组 OCF 命令:

  1. The OGF of 0x08 groups OCF commands for LE Controllers:

对于 LE 控制器命令,OGF 代码定义为 0x08.(蓝牙规范版本 4.0 [Vol 2],第 1114 页)

For the LE Controller Commands, the OGF code is defined as 0x08. (Bluetooth Specification Version 4.0 [Vol 2], page 1114)

因为 0x0008 OCF 命令是控制器命令,所以你必须使用 0x08 OGF 代码.使困惑?忘了它.只知道您使用 0x08 0x0008 使用 hcitool 设置广告数据.

Because the 0x0008 OCF command is a controller command, you have to use the 0x08 OGF code with it. Confused? Forget it. Just know you use 0x08 0x0008 to set the advertising data using hcitool.

开始广告的字节顺序如下:

The byte sequence starting the advertisement is as follows:

1E Number of bytes that follow in the advertisement
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 Company identifier code LSB
00 Company identifier code MSB (0x004C == Apple)
02 Byte 0 of iBeacon advertisement indicator
15 Byte 1 of iBeacon advertisement indicator

-- 蓝牙规范版本 4.0 [Vol 3],广告和扫描响应数据格式"p.375

-- Bluetooth Specification Version 4.0 [Vol 3], "ADVERTISING AND SCAN RESPONSE DATA FORMAT" p. 375

-- 蓝牙规范版本 4.0 [Vol 3],附录 C(规范):EIR 和广告格式",第 401 页

-- Bluetooth Specification Version 4.0 [Vol 3], Appendix C (NORMATIVE): EIR AND AD FORMATS", p. 401

功率字段只是一个一字节的二进制补码数,表示相距相隔一处的 RSSI 中的测量功率".简单来说

The power field is simply a one byte two's complement number representing the "measured power" in RSSI at one meeter away. In simpler terms

这是它的工作原理:

  1. 拿着 iBeacon 扫描仪(例如 定位 iBeacon 对于 iOS)距离 iBeacon 发射器一米.
  2. 在 RSSI 中读取其信号强度.它将是一个介于 -1 和 -127 之间的数字.(-1 非常强,-127 非常弱)
  3. 使用二进制补码将此数字转换为十六进制.(添加 256 然后转换为十六进制)
  1. Hold an iBeacon scanner (like Locate for iBeacon for iOS) one meter away from your iBeacon transmitter.
  2. Read its signal strength in RSSI. It will be a number between -1 and -127. (-1 is very strong, -127 is very weak)
  3. Convert this number into a hex using two's complement. (Add 256 then convert to hex)

注意:功率场可以是 80-FF.如果是00,iOS根本不会做距离计算.您可以在此处阅读有关如何使用它的更多信息.

Note: The power field can be 80-FF. If it is 00, iOS will not do a distance calculation at all. You can read more on how this is used here.

这篇关于了解 iBeacon 数据:功率字段和其他字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆