0

我可以让我的 BLE 设备作为 Eddystone Beacon 进行广播。它使用“ http://www.cypress.com ”广播 Eddystone URL。现在我想将该 URL 更改为特定于国家/地区的扩展,例如"---.com.tr"

是 Eddystone 协议的 GitHub 源代码。它没有提供有关使用特殊 URL 扩展的任何线索。你知道如何实现它吗?

这也是我项目中的代码片段:

cyBle_discoveryData.advData[13] = 0x00;     /* URL scheme- http://www. */
cyBle_discoveryData.advData[14] = 0x63;     /* Encoded URL - 'c' */
cyBle_discoveryData.advData[15] = 0x79;     /* Encoded URL - 'y' */
cyBle_discoveryData.advData[16] = 0x70;     /* Encoded URL - 'p' */
cyBle_discoveryData.advData[17] = 0x72;     /* Encoded URL - 'r' */
cyBle_discoveryData.advData[18] = 0x65;     /* Encoded URL - 'e' */
cyBle_discoveryData.advData[19] = 0x73;     /* Encoded URL - 's' */
cyBle_discoveryData.advData[20] = 0x73;     /* Encoded URL - 's' */
cyBle_discoveryData.advData[21] = 0x00;     /* Expansion - .com */

/* ADV packet length */
cyBle_discoveryData.advDataLen = 22;
4

1 回答 1

1

了解 .com 等扩展名的特殊扩展代码对于节省字节很有用,但完全是可选的。您也可以像这样简单地放入扩展的字节:

...
cyBle_discoveryData.advData[20] = 0x73;     /* Encoded URL - 's' */
cyBle_discoveryData.advData[21] = 0x00;     /* Expansion - .com */
cyBle_discoveryData.advData[22] = 0x2e;     /* Encoded URL - '.' */
cyBle_discoveryData.advData[23] = 0x74;     /* Encoded URL - 't' */
cyBle_discoveryData.advData[24] = 0x72;     /* Encoded URL - 'r' */

/* ADV packet length */
cyBle_discoveryData.advDataLen = 25;

因此,虽然 .tr 没有特殊代码,但您可以简单地将其 ASCII 字节放入广告中。

于 2016-03-16T11:56:38.680 回答