Pab*_*ark 13 c++ bluetooth bluez iot intel-edison
我正在为英特尔爱迪生编写一个蓝牙驱动程序.Board软件是最新的,我正在使用基于Eclipse的IDE进行开发.此爱迪生版本中的Bluez版本号为5.37.
我正在设计一个必须满足以下要求的系统:
最后一项是问题,因为我可以检测传感器设备,但我无法使用bluez5接口配对它们.到目前为止,我已尝试使用D-BUS接口,但由于我不断收到以下错误消息,因此无法正常工作:
接口"org.bluez.Manager"上带有签名"s"的方法"FindAdapter"不存在
代码在此处显示.请注意:
码:
DBusMessage *msg, *reply;
DBusError err;
const char *reply_path;
char *path;
msg = dbus_message_new_method_call("org.bluez", "/","org.bluez.Manager", "FindAdapter");
dbus_message_append_args(msg, DBUS_TYPE_STRING, &adapter,DBUS_TYPE_INVALID);
dbus_error_init(&err);
reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
dbus_message_unref(msg);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
为了给您一个答案,配对和连接与device-api.txt相关联。要调用这些方法,您可以发送 dbus 消息(就像在上面的代码中所做的那样)或使用以下参数构建一个 Proxy 对象(在文档中找到):
名称:“org.bluez”
接口“org.bluez.Device1”
路径:“/org/bluez/dev_AA_BB_CC_DD_EE”,其中 AA_BB_CC_DD_EE 是您的设备 MAC 地址。
如果您选择构建代理对象,则可以通过代理调用 Pair 或 Connect 等方法。
您能解释一下您在上面的代码中想要实现的目标吗?我知道您想查找要使用的适配器(我看到“FindAdapter”方法),但是您似乎已经知道您的适配器名称是“hci0”。
我最近一直在使用 Bluez 公开的 DBus API,对“org.bluez.Manager”接口不熟悉。
在官方文档(https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc)中快速搜索后,我找到了以下提交,其中指定该接口于 2012 年被删除: https ://git.kernel.org/cgit/bluetooth/bluez.git/commit/doc?id=86a7b07c22f3a595ba3c48092359287905bf0878
我还注意到您正在使用 DBus 低级 API,正如 freedesktop 本身所建议的那样(在页面底部阅读: https: //dbus.freedesktop.org/doc/api/html/group__DBus.html),这是非常复杂的 API,可用于创建其他语言的绑定。如果可以的话,切换到 GLib GDBus 以获得更简单的 API。