【问题标题】:bluez: connection error with 5bluez:与 5 的连接错误
【发布时间】:2016-03-23 17:21:11
【问题描述】:
hci_le_create_conn(device,htobs(0x0010),htobs(0x0010),0,0,
                     peeraddr,0,15,15,0,3200,1,1,0,1000);

我得到上面的errno = 5表格,这意味着命令没有被接收到,并且没有在主机控制器中处理。

谁能告诉我哪里错了?

我想将我的蓝牙智能设备与我的 linux 计算机连接,但它不起作用。 下面是函数hci_le_create_conn的参数。

int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
        uint8_t initiator_filter, uint8_t peer_bdaddr_type,
        bdaddr_t peer_bdaddr, uint8_t own_bdaddr_type,
        uint16_t min_interval, uint16_t max_interval,
        uint16_t latency, uint16_t supervision_timeout,
        uint16_t min_ce_length, uint16_t max_ce_length,
        uint16_t *handle, int to)

【问题讨论】:

  • 你真的必须使用 hci_lib 而不是 DBUS 接口吗? hci_lib 没有得到官方支持,沿着这条路线走只是一条通往痛苦恕我直言的途径(我之前已经评估过它)。
  • @kaylum - DBUS 接口是否允许访问非标准和/或不属于配置文件的 GATT 属性?当我开始使用 Bluez 时,我被告知使用 DBUS 无法做到这一点,所以我最终使用了内核调用(这是共享库最终所做的)。
  • @TimTisdall 是的。就在两三个月前。新的gatt API 现已推出。但它在技术上仍然是实验性的,可以通过将 -E 传递给 bluetoothd 来使用。我用过,效果很好。
  • 查看我包含的答案herehere,了解有关 DBus 接口的更多信息!

标签: bluez bluetooth-lowenergy


【解决方案1】:

我应该在运行函数之前运行sudo hciconfig hci0 downsudo hciconfig hci0 up

无论如何,我已成功连接到我的 BLE 设备!

【讨论】:

  • 我很确定hciconfig hci0 reset 就是这样做的。
  • 查看hciconfig hci0 reset的源代码,在你的程序中实现类似的功能,所以每次你不需要从命令行发出它
  • hciconfig 正在逐步淘汰 BlueZ,就像 hcitool 等一样。它利用原始套接字调用。请不要推荐这些作为答案。
【解决方案2】:

使用蓝牙守护程序重置您的硬件:

sudo bluetoothctl

power off

power on

我相信 BlueZ 正在逐步淘汰 hciconfighcitool 等工具。更多信息可以在here找到。

【讨论】:

    猜你喜欢
    • 2015-05-08
    • 2017-09-17
    • 2013-05-07
    • 2015-03-08
    • 2018-11-20
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    • 2015-11-25
    相关资源
    最近更新 更多