【问题标题】:GATT client not working on BlueZ 5.19GATT 客户端不适用于 BlueZ 5.19
【发布时间】:2017-06-25 09:50:05
【问题描述】:

我正在尝试让 GATT 客户端在运行 BlueZ 5.19 的 Linux 系统上运行。不幸的是,这个系统上既没有 Python 也没有 glib,所以我唯一的选择是使用 libdbus。我有没有提到我以前从未使用过 D-Bus?我在另一个系统上有一个 GATT 服务器,它通过其 16 字节 UUID 提供和宣传自定义服务。我正在尝试让基于 BlueZ 的系统访问此服务。我已经验证我可以通过它所宣传的 UUID 发现服务器,并且我可以让 BlueZ 连接到它。我的客户端应用程序已成功调用 Bluez 的 RegisterProfile 方法,传递了服务器通告的 UUID,但 BlueZ 从未调用我的 NewConnection 方法。在 RegisterProfile 调用的选项中,我将“Role”设置为“client”,“AutoConnect”设置为 TRUE,“RequireAuthorization”和“RequireAuthentication”都设置为 FALSE。我正在使用 -E(实验)选项运行蓝牙。

如果我使用 -E 和调试选项在前台运行 bluetoothd,这就是我在启动客户端应用程序时看到的:

bluetoothd[2126]: src/profile.c:register_profile() sender :1.20
bluetoothd[2126]: src/profile.c:create_ext() Created "myRemoteControlProfile"
bluetoothd[2126]: src/profile.c:ext_device_probe() myRemoteControlProfile probed with UUID 119649b6-b656-22ae-e611-ba85a04effc5
bluetoothd[2126]: src/service.c:change_state() 0x950d0: device 24:71:89:09:AD:09 profile myRemoteControlProfile state changed: unavailable -> disconnected (0)

“myRemoteControlProfile”是我在 Bluez 注册的配置文件的名称,“119649b6-b656-22ae-e611-ba85a04effc5”是我在 RegisterProfile 调用中传递的 UUID,24:71:89:09:AD:09是我试图与之交互的 GATT 服务器,所以 BlueZ 似乎知道这个远程设备提供了我正在寻找的服务。当我在服务器设备上观看时,我从来没有看到 BlueZ 连接到它。当 BlueZ 看到设备提供了我在 RegisterProfile 中传递的服务时,它不应该连接到设备吗?为什么我没有收到 NewConnection 方法调用?我的注册个人资料永远不会超过“断开连接”状态是什么意思?我知道 GATT API 在 BlueZ 5.19 中仍被认为是实验性的;我什至应该期望这行得通吗?谢谢!

顺便说一句,这个问题与https://stackoverflow.com/questions/36480516/bluez5-37-org-bluez-profilemanager1-registerprofile-cant-detect-green-throttle 中描述的问题几乎相同。不幸的是,那里没有提供任何答案。

【问题讨论】:

    标签: bluetooth bluez


    【解决方案1】:

    我已经能够通过升级到 BlueZ 5.43 来解决这个问题。我仍然没有得到 NewConnection 方法调用,但是如果我通过它所宣传的服务的 UUID 检测到远程设备并手动连接到它,那么当我在 org.bluez 上执行 GetManagedObjects 时,服务的所有特征现在都会出现,这在 BlueZ 5.19 中没有发生。

    【讨论】:

    • 您应该始终尝试使用最新的可用版本 BlueZ,尤其是因为 5.4x 之前的版本在 LE 功能和稳定性方面非常糟糕。您在使用bluetoothd 时是否与 DBus 进行过交互?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 2017-11-01
    • 2017-09-01
    • 1970-01-01
    相关资源
    最近更新 更多