【问题标题】:How to find it out BLE device is got unpair and connect it again如何找出BLE设备已取消配对并重新连接
【发布时间】:2018-11-27 05:26:23
【问题描述】:

在 bluez5.50 中,连接建立完成后,如果我取消配对设备并再次进入发现模式,则无法连接(预期行为)。但我想将 BLE 设备连接到相同的运行堆栈。 hcidump 在 BLE 设备进入睡眠模式或从设备端取消配对时也会显示相同的事件。

HCI 事件:Disconn Complete (0x05) plen 4 状态 0x00 句柄 69 原因 0x16 原因:连接被本地主机终止

因此无法找出确切发生的事件(睡眠/取消配对)。有人可以为我提供解决方案如何找出取消配对事件并尝试再次连接吗?

【问题讨论】:

    标签: bluez


    【解决方案1】:

    您使用什么进行连接配对?您可以尝试通过 bluetoothctl 执行此操作,如下所示:-

    #bluetoothctl
    [bluetoothctl]scan on #Scan for a few seconds until you find your device
    [bluetoothctl]scan off #Stop scanning once you have found your device
    [bluetoothctl]connect 00:11:22:33:44:55
    [bluetoothctl]pair 00:11:22:33:44:55
    [bluetoothctl]disconnect 00:11:22:33:44:55
    [bluetoothctl]remove 00:11:22:33:44:55 # This is if you want to forget the device.
    [bluetoothctl]scan on #Scan for a few seconds until you find your device
    [bluetoothctl]scan off #Stop scanning once you have found your device
    [bluetoothctl]connect 00:11:22:33:44:55
    

    如果这不起作用,请尝试在另一个终端中使用 btmon 并查看连接失败的原因。

    我希望这会有所帮助。

    【讨论】:

    • 在开始配对或连接之前,您可能还需要trust设备。
    • 我知道连接失败的原因,因为在连接建立完成后,我取消了我的 BLE 设备配对(使用设备中的取消配对组合键)。问题是:再次取消配对 BLE 设备后,我将设备置于发现模式以再次连接。但相同的运行 bluez 堆栈无法连接 BLE 设备。示例:假设您将智能控制遥控器连接到电视并使用某些组合键取消配对设备(不是从应用程序端,设备端)。所以在运行 bluez 时如何重新连接它或者我们如何找出设备已取消配对。
    • 我正在使用 Fedora 25/ bluez-5.48 和 BLE 设备(智能电视遥控器)。在haltest中使用的命令#bluetooth create_bond 48:d0:cf:ff:d1:ad #hidhost connect 48:d0:cf:ff:d1:ad #gattc get_device_type 48:d0:cf:ff:d1:ad #gattc register_client 48 :d0:cf:ff:d1:ad #gattc connect 2 48:d0:cf:ff:d1:ad #gattc search_service 3 #gattc get_characteristic 3 {1812,4,1} #gattc register_for_notification 2 48:d0:cf: ff:d1:ad {1812,4,1} {2a4d,4}
    猜你喜欢
    • 2013-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 2016-01-30
    • 1970-01-01
    相关资源
    最近更新 更多