c - AltBeacon - 从自定义字节数据创建
问题描述
我正在尝试使用自定义数据创建一个 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)
};
推荐阅读
- json - 无法从 Swish QR 代码 API 理解此 JSON 模式
- javascript - 无法读取上下文提供程序中的 useReducer 挂钩更新的状态
- node.js - 我如何使用 nodejs (puppeteer) 监控网络活动
- r - 如何从 R 中的 sqldf 输出中获取列的总和?
- javascript - Angular - 如何使用 InnerHtml 执行存储在字符串中的脚本
- vue.js - 如何使用多个选择按钮过滤 Vue.js 中的数组?
- c++ - 将函数 SetKeys 添加到 MFRC522 库
- azure - Azure App Service Deploy 返回 (403) Forbidden with IP 限制
- php - 如何修复 Yii2 自定义视图控制器的 URL
- git - 可以将 Composer 配置为使用 http 而不是 git clone git@