AltBeacon - 从自定义字节数据创建

AltBeacon - create from custom bytes data

我正在尝试使用自定义数据创建 AltBeacon。我看到了 AltBeacon 协议格式 (https://github.com/AltBeacon/spec),但我不知道如何模拟数据以便我的设备传输 AltBeacon。

   #define ALT_BEACON_DATA_LEN (28)

   static const uint8_t alt_beacon_data[ALT_BEACON_DATA_LEN] = {
      [0] = 0x1B,          // AD Lenght
      [1] = 0xFF,          // AD Type
      [2 ... 3] = 0x0047,        // MGF ID
      // Alt Beacon ID
      [26] = 0x11,           // Ref RSSI
      [27] = 0x05,           // MGF Reserved
   };

你能帮帮我吗?如何以正确的方式设置字节

试试这个:

static const uint8_t alt_beacon_data[ALT_BEACON_DATA_LEN] = {
  [0] = 0x1B,   // AD Length
  [1] = 0xFF,   // AD Type
  [2] = 0x47,   // Little Endian Byte 0 of MGF ID 0x0047
  [3] = 0x00,   // Little Endian Byte 1 of MGF ID 0x0047
  [4] = 0xBE,   // Big Endian Byte 0 of Beacon Type Code 0xBEAC
  [5] = 0xAC,   // Big Endian Byte 1 of Beacon Type Code 0xBEAC
  [6] = 0x2F,   // Big Endian Byte 0 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [7] = 0x23,   // Big Endian Byte 1 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [8] = 0x44,   // Big Endian Byte 2 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [9] = 0x54,   // Big Endian Byte 3 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [10] = 0xCF,  // Big Endian Byte 4 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [11] = 0x6D,  // Big Endian Byte 5 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [12] = 0x4A,  // Big Endian Byte 6 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [13] = 0x0F,  // Big Endian Byte 7 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [14] = 0xAD,  // Big Endian Byte 8 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [15] = 0xF2,  // Big Endian Byte 9 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [16] = 0xF4,  // Big Endian Byte 10 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [17] = 0x91,  // Big Endian Byte 11 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [18] = 0x1B,  // Big Endian Byte 12 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [19] = 0xA9,  // Big Endian Byte 13 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [20] = 0xFF,  // Big Endian Byte 14 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [21] = 0xA6,  // Big Endian Byte 15 of UUID 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
  [22] = 0x00,  // Big Endian Byte 0 of Major 0x0001
  [23] = 0x01,  // Big Endian Byte 1 of Major 0x0001
  [24] = 0x00,  // Big Endian Byte 0 of Minor 0x0002
  [25] = 0x02,  // Big Endian Byte 1 of Minor 0x0002
  [26] = 0xC5,  // Binary Coded Decimal of -59 dBm
  [27] = 0x00,  // MGF Reserved (often for battery level 0-100 percent, otherwise zero)
};