我正在尝试使用自定义数据创建一个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)
};

关于c - AltBeacon-从自定义字节数据创建,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60156739/

10-09 04:39