Understanding iBeacon data : the power field and other bytes

后端 未结 1 1438
抹茶落季
抹茶落季 2021-01-03 03:47

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

There is already some nice answers which expl

相关标签:
1条回答
  • 2021-01-03 04:28

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

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

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

      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.

    2. 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
      

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

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

    3. 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

      Here is how that works:

      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)

    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.

    0 讨论(0)
提交回复
热议问题