本文介绍了BlueZ 5.30:D-Bus GATT API-简单地发现并连接到C语言中的BLE设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在BlueZ的最新版本(5.30)中,最重要的是GATT D-Bus API的完成.我的目标是以编程方式(用C语言)作为BLE客户端:

With the last release of BlueZ (5.30) the highlight was the completion of the GATT D-Bus apis. My goal is to programmatically (in C), as a BLE client:

  1. 扫描ble设备(我可以使用hci层进行扫描)
  2. 连接到广告BLE设备
  3. 获取UUID
  4. 执行读取和写入操作句柄

BlueZ社区强烈建议使用GATT-Dbus api来完成此任务.经过多次搜索和抓挠头后,我未能成功找到通过GATT-DBUs API执行此操作的正确方法或示例.看起来比直接使用GATT层更为复杂.不幸的是,BlueZ删除了直接调用gatt的权限.

The BlueZ community is strongly suggesting to use the GATT-Dbus api to accomplish this. After multiple searches and head scratching I was not successful to find a proper way or example that would perform this through GATT-DBUs api. It seems more complicate than just use directly the GATT layer. Unfortunately BlueZ removed direct access to make calls to gatt.

我非常接近将GATT源文件从Bluez中拉出来,将其编译为自己的独立库,并直接使用GATT层和调用来连接和执行对ble设备服务器的读取/写入.我知道,与DBUS-GATT api相比,这不是建议的方法,但是我没有选择.

I'm very close to just pull the GATT source files out from Bluez, compile it as it's own independent library and directly use the GATT layer and calls to connect and execute reads/writes to ble device server. I know it is not the suggested way compared to the DBUS-GATT api but I'm out of options.

如果有人对此有任何建议或建议(带有一些示例代码),请提出建议.

If anybody has any input on this or suggestion (with some sample code) please advise.

先谢谢您!

推荐答案

以DBUS GATT API开头的最佳方法是在此处查看源代码:"> http://git.kernel.org/cgit/bluetooth/bluez.git/tree/

The best way to start with DBUS GATT API is to hace a look at the source code here: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/

client文件夹下,您可以找到有关如何使用DBUS GATT API的完整示例.实际上,这就是bluetoothctl工具的来源.

Under client folder you can find a full sample of how to use the DBUS GATT API. Actually that is the source of bluetoothctl tool.

请注意,DBUS GATT API仍处于试验阶段,但您可以使用-E标志启用它运行蓝牙服务.

Note that DBUS GATT API is still experimental but you can enable it running bluetoothd service with -E flag.

这篇关于BlueZ 5.30:D-Bus GATT API-简单地发现并连接到C语言中的BLE设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 08:44