1

为 Bluez BLE 编写 gdbus 客户端(5.48 版)

使用 gdbus-codegen 工具生成代理和骨架。XML 内容具有以下详细信息。

<interface name="org.bluez.LEAdvertisement1">
        <method name="Release">
            <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
        </method>

        <annotation name="org.freedesktop.DBus.Properties.PropertiesChanged" value="const"/>
        <property name="Type" type="s" access="read"/>
        <property name="ServiceUUIDs" type="as" access="read"/>
        <property name="ManufacturerData" type="a{qv}" access="read"/>
        <property name="SolicitUUIDs" type="as" access="read"/>
        <property name="Includes" type="as" access="read"/>
        <property name="ServiceData" type="a{sv}" access="read"/>
        <property name="IncludeTxPower" type="b" access="read"/>
        <property name="LocalName" type="s" access="read"/>
        <property name="Appearance" type="q" access="read"/>
        <property name="Duration" type="q" access="read"/>
        <property name="Timeout" type="q" access="read"/>
    </interface>

以上所有属性都从我的客户端分配给默认值。当我使用 d-feet 进行反省时。

但是 bluetoothctl 这些值没有分配给默认值。

我调试了

bluez/src/Advertising.c function client_proxy_added()->parse_advertisement()

g_dbus_proxy_get_property returns TRUE for properties set by bluetoothctl, others it returns FALSE.

但是使用自动生成的代码,即使没有设置任何属性。g_dbus_proxy_get_property 能够获取其解析的所有属性和默认值。由于上述在启动广告时面临以下问题。1)超时默认值为零,它立即超时。2) 当设置了 include 属性时,即使没有设置 name 属性也会被解析。bluez 抛出错误“已包含本地名称”。

我们如何使用 gdbus 自动生成的代码做出与 bluetoothctl 相同的行为?

4

0 回答 0