【发布时间】: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