【问题标题】:Connect to BLE device with gatttool in non-interactive mode在非交互模式下使用 gatttool 连接到 BLE 设备
【发布时间】:2023-03-31 02:19:01
【问题描述】:

我正在尝试从我的体重秤蓝牙低功耗设备中读取数据。测量后,秤会通过蓝牙发布新数据约一分钟。我可以像这样使用 gatttool 阅读它:

gatttool -b MAC_ADDRESS -I
connect

-I 选项以交互模式运行 gatttool。然后,成功连接后,我得到这样的数据:

Indication   handle = 0x0012 value: 02 9c 0e e4 07 08 1c 0b 02 0f 
Indication   handle = 0x0012 value: 02 68 0b e4 07 08 1c 0c 03 06 
Indication   handle = 0x0012 value: 02 18 47 e4 07 08 1f 07 11 3a

我可以从中读取值,但我需要在 gatttool 非交互模式下执行此操作,因此我可以使用 QProcess 类在我的 Qt 应用程序中读取它的输出。 gatttool -h 没有多说如何与设备连接。没有类似的命令: gatttool -b MAC_ADDRESS connect。有读取或写入的命令,但我不需要这个。我只想连接并等待来自设备的即将到来的数据。 谁能告诉我如何使用 gatttool 在非交互模式下连接?

谢谢。

【问题讨论】:

    标签: bluetooth-lowenergy gatttool


    【解决方案1】:

    gatttool 是 BlueZ 项目 deprecated 的八个工具之一。

    直接在 Qt 中处理 BLE 通知不是更好吗?

    例如:https://doc.qt.io/archives/qt-5.7/qtbluetooth-heartlistener-example.html

    【讨论】:

    • 问题是我不能让它以 Qt 方式工作,这就是为什么我正在寻找另一个解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 2017-03-07
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 1970-01-01
    相关资源
    最近更新 更多