首页 > 解决方案 > Bluez BLE 外设使用 ADV 数据宣传自定义特性

问题描述

是否有允许广告自定义 UUID 和特征以及特定 ADV 数据的示例应用程序?Bluez 的文档较少。任何帮助表示赞赏。

标签: bluez

解决方案


你有哪个版本的 BlueZ?使用较新版本的 BlueZ(例如 5.50),您可以从命令行使用 bluetoothctl 执行此操作,如下所示:-

#bluetoothctl
[bluetooth]# menu advertise
[bluetooth]# uuids 0x1800 0x1801 0x1802
[bluetooth]# name MyDevice
[bluetooth]# data 0 01 02 03
[bluetooth]# back
[bluetooth]# advertise on

这允许您设置自定义 UUID、广告数据和广告设备名称。您可以深入研究 BlueZ 源代码,了解如何使用 C 实现这一点。

我希望这有帮助。


推荐阅读