bluetooth-lowenergy - 在非交互模式下使用 gatttool 连接到 BLE 设备
问题描述
我正在尝试从我的体重秤蓝牙低功耗设备中读取数据。测量后,秤会通过蓝牙发布新数据约一分钟。我可以像这样使用 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 非交互模式下执行此操作,因此我可以在我的 Qt 应用程序中使用 QProcess 类读取它的输出。gatttool -h
关于如何与设备连接并没有多说。没有类似的命令:
gatttool -b MAC_ADDRESS connect
。有读取或写入的命令,但我不需要这个。我只想连接并等待来自设备的即将到来的数据。谁能告诉我如何使用 gatttool 以非交互模式连接?
谢谢。
解决方案
gatttool 是BlueZ 项目已弃用的八个工具之一。
直接在 Qt 中处理 BLE 通知不是更好吗?
例如:https ://doc.qt.io/archives/qt-5.7/qtbluetooth-heartlistener-example.html
推荐阅读
- reactjs - 如何在 ReactJS 中实现混合渲染
- macos - 让 Scintilla 使用 Option + Shift + 箭头
- c++ - 使用 MinGW 链接到 exe 时的多个定义
- sql - 分别为多个连接表选择 COUNT 值
- html - 移动设备中的对象未按顺序放置
- apache-flink - flink SQL 1.13.0&1.13.1 elasticsearch sink 失败
- r - 是否有 R 函数来确定两组之间生存不再显着不同的时间点?
- php - 如何在 Laravel 中测试 Http Pool?
- android - Android:如何使应用程序仅在真实的物理移动设备上运行
- excel - 使用相同单元格 ID 在 Excel 中进行高级粘贴