我正在尝试使用 C++ 在我的 Raspberry Pi 4 上创建 BLE GATT 服务。搜索了一段时间但找不到有用的提示/示例。
更多详情: 我能够使用命令创建 GATT 服务和特征:
#bluetoothctl
[bluetoothctl] menu gatt
[bluetoothctl] register-service 0xFFFF #
[bluetoothctl] register-characteristic 0xAAAA read,write #
[bluetoothctl] register-application #
我想使用 C++ 代码实现相同的目标。
我在
https://github.com/Vudentz/BlueZ/blob/master/doc/gatt-api.txt中找到了
void RegisterApplication(object application, dict options)
的定义,但它没有提供很多细节。我的问题是:
对于这个 RegisterApplication 函数,我应该为“对象应用程序”和“dic 选项”添加什么?有没有格式的例子
g_dbus_proxy_call(
Proxy,
"RegisterApplication",
Params,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
NULL,
NULL);
显示如何为我的服务和特征(使用命令注册)构建“参数”?
您需要在 D-Bus 中构建 BLE GATT 服务层次结构,然后使用
RegisterApplication
告诉 BlueZ 服务的顶层位于 D-Bus 上的位置。
要使用 D-Bus 的说法,需要使用 D-Bus 对象创建本地 BlueZ 服务,然后发布。它是您创建的已发布本地 BlueZ 服务层次结构的 D-Bus 对象,它是
RegisterApplication
的第一个参数
您可能还想查看以下项目,看看他们是如何做到的: https://github.com/netttlep/gobbledegook