小编Pab*_*ark的帖子

如何在C++中使用Bluez5 DBUS API来配对和连接新设备?

我正在为英特尔爱迪生编写一个蓝牙驱动程序.Board软件是最新的,我正在使用基于Eclipse的IDE进行开发.此爱迪生版本中的Bluez版本号为5.37.

我正在设计一个必须满足以下要求的系统:

  • 扫描附近的蓝牙设备.[X]
  • 根据名称和MAC地址检测传感器设备.[X]
  • 自动配对和连接传感器设备.[]

最后一项是问题,因为我可以检测传感器设备,但我无法使用bluez5接口配对它们.到目前为止,我已尝试使用D-BUS接口,但由于我不断收到以下错误消息,因此无法正常工作:

接口"org.bluez.Manager"上带有签名"s"的方法"FindAdapter"不存在

代码在此处显示.请注意:

  • DBusConnection*conn - > DBUS_BUS_SYSTEM
  • const char*adapter - >"hci0".

码:

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)

有任何想法吗?

c++ bluetooth bluez iot intel-edison

13
推荐指数
1
解决办法
2759
查看次数

标签 统计

bluetooth ×1

bluez ×1

c++ ×1

intel-edison ×1

iot ×1