【问题标题】:Linux BlueZ dbus communicationLinux BlueZ dbus 通信
【发布时间】:2015-10-01 13:17:17
【问题描述】:

我使用 BlueZ 5.30 和内核 3.13.0-32,我需要通过 DBus 在我的应用程序中实现读/写特征功能。

我正在使用 BlueZ 测试脚本来建立连接:

“测试发现”,然后是“测试设备连接”。

问题是我没有看到 DBus (org.bluez) 中显示任何服务。使用 d-feet 应用程序我只能看到:

"/org/bluez/hci0/dev_btaddr" 接口 org.bluez.Device1 org.freedesktop/DBus.Introspectable org.freedesktop.DBus.Properties

在“/var/log/syslog”中我可以看到很多:

" bluetoothd[715]: 无法使用句柄 0x0045 为设备注册 GATT 服务..."

使用 gatttool 我能够读取/写入特征、原色等。在 hcidump 下,我看到所有特征都被正确读取。

但是,从 DBus PoV 中,只有 Device1 接口可用。

这是我的 BlueZ 配置: " ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-library --disable-systemd --enable-experimental --enable-维护者模式——启用调试 "

我在看这里:“http://i-miss-erin.blogspot.com/2010/12/gatt-related-dbus-api.html”,但正如我所提到的,这里没有显示任何界面或服务。

为了测试,我使用接近和隐藏设备。 在隐藏的情况下,正确连接后,我可以在终端窗口(隐藏键盘设备)中看到字符,因此我认为它可以正常工作。

有什么建议吗?

【问题讨论】:

  • 我已经解决了我的问题。问题是由于没有“-E”的蓝牙运行导致BlueZ的实验部分
  • 您是如何最终将 -E 添加到启动中的?我一直在尝试将它添加到 /etc/init.d/bluetooth 中的守护进程,但这似乎没有奏效。你在哪里添加的?

标签: linux dbus bluez gatt


【解决方案1】:

您必须为您的蓝牙设备激活实验性功能才能启用 GATT 服务。

在 Debian 系统上,您可以通过将

NOPLUGIN_OPTION="-E"

进入/etc/default/bluetooth 文件。

重启后,为了让我的设备(Logitech MX Master)在我的 Debian Stretch 上正常工作,我还必须使用 bluetoothctl 命令手动配对和信任它。我使用 Gnome 的图形蓝牙工具没有成功。

【讨论】:

  • 对于较新的基于 Systemd 的系统,将 /lib/systemd/system/bluetooth.service 复制到 /etc/systemd/system/bluetooth.service 并将 ExecStart 行更改为 ExecStart=/usr/lib/bluetooth/bluetoothd -E。
猜你喜欢
  • 2016-01-24
  • 2015-06-02
  • 2015-12-25
  • 2019-05-08
  • 2012-09-02
  • 2019-02-24
  • 2014-02-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多