我正在尝试从我的体重计蓝牙低能耗设备中读取数据。测量结束后,天平通过蓝牙通知新的数据大约一分钟。我可以像这样使用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在非交互模式下连接?
谢谢。
发布于 2020-08-31 21:19:35
gatttool是已经被BlueZ项目deprecated的八个工具之一。
直接在Qt中处理BLE通知不是更好吗?
例如:https://doc.qt.io/archives/qt-5.7/qtbluetooth-heartlistener-example.html
https://stackoverflow.com/questions/63670959
复制相似问题