bluetooth - 即使已配对,BlueZ 仍出现“Pin 或 Key 缺失”
问题描述
我正在为 gatt 服务开发基于 linux(bluez 5.48) 和 QT 应用程序的 BLE 外围设备。我还在开发用于连接设备的 Android 手机应用程序。
我的问题是在第二个连接(#3)上,如下程序,
- 设备开始广告 -> Android 应用程序扫描并连接 -> Android 应用程序尝试写入具有身份验证安全性的特征 -> 发生身份验证不足并在手机上弹出密码输入 -> 输入密码并配对成功并写入特点还可以。
- 断开
- 设备开始广告 -> Android 应用程序扫描并连接 -> Android 应用程序尝试写入具有身份验证安全性的特征 -> 发生身份验证不足并在手机上弹出密码输入????????????
我在设备的日志中发现“pin or key missing”错误。由于手机的随机 MAC 地址,我的设备似乎将手机识别为新设备。这个问题的任何想法或解决方案?
ps:bluez设备设置为DisplayOnly
谢谢,卡尔文
我添加了上述测试序列的设备日志。为什么会发生“正在删除临时设备...”?
=============== 第一次连接并与我的 android 测试应用配对:连接 -> 绑定 -> 与应用断开连接 =========
12 月 17 日 07:35:38 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_ref() 0xfd1000: ref=1
12 月 17 日 07:35:38 蓝牙 [368]:../bluez-5.50/src/agent.c:register_agent() 代理:1.49
12 月 17 日 07:35:38 蓝牙 [368]:../bluez-5.50/src/agent.c:unregister_agent() 代理:1.49
12 月 17 日 07:35:38 bluetoothd[368]:../bluez-5.50/src/agent.c:agent_disconnect() 代理:1.49 已断开连接
12 月 17 日 07:35:38 蓝牙 [368]:../bluez-5.50/src/agent.c:agent_destroy() 代理:1.49
12 月 17 日 07:35:38 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_unref() 0xfd1000: ref=0
12 月 17 日 07:35:38 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_ref() 0xfd1000: ref=1
12 月 17 日 07:35:38 蓝牙 [368]:../bluez-5.50/src/agent.c:register_agent() 代理:1.49
12 月 17 日 07:35:38 bluetoothd[368]: ../bluez-5.50/src/agent.c:add_default_agent() 默认代理设置为:1.49 /org/bluez/agent
12 月 17 日 07:35:46 bluetoothd[368]: ../bluez-5.50/src/adapter.c:connected_callback() hci0 device 5C:CB:99:7F:77:02 connected eir_len 0
12 月 17 日 07:35:47 bluetoothd[368]: ../bluez-5.50/src/adapter.c:user_passkey_notify_callback() hci0 5C:CB:99:7F:77:02
12 月 17 日 07:35:47 bluetoothd[368]: ../bluez-5.50/src/adapter.c:user_passkey_notify_callback() 密码 859060 输入 0
12 月 17 日 07:35:47 bluetoothd[368]: ../bluez-5.50/src/device.c:new_auth() 请求 5C:CB:99:7F:77:02 的代理身份验证
12 月 17 日 07:35:47 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_ref() 0xfd1000: ref=2
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:new_irk_callback() hci0 new IRK for 5C:CB:99:7F:77:02 RPA 00:00:00: 00:00:00
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:new_csrk_callback() hci0 new CSRK for 5C:CB:99:7F:77:02 type 3
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:new_csrk_callback() hci0 new CSRK for 5C:CB:99:7F:77:02 type 2
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:new_long_term_key_callback() hci0 new LTK for 5C:CB:99:7F:77:02 type 1 enc_size 16
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/device.c:device_set_bonded()
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/device.c:device_bonding_complete() 绑定 (nil) 状态 0x00
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_unref() 0xfd1000: ref=1
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:resume_discovery()
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:new_long_term_key_callback() hci0 new LTK for 5C:CB:99:7F:77:02 type 1 enc_size 16
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/device.c:device_set_bonded()
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/device.c:device_bonding_complete() 绑定 (nil) 状态 0x00
12 月 17 日 07:35:56 bluetoothd[368]: ../bluez-5.50/src/adapter.c:resume_discovery()
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/adapter.c:dev_disconnected() 设备 5C:CB:99:7F:77:02 已断开连接,原因 3
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/adapter.c:adapter_remove_connection() 12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/plugins/policy .c:disconnect_cb() 原因 3
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 5C:CB:99:7F:77:02 类型 1 状态 0xe
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/device.c:device_bonding_complete() 绑定 (nil) 状态 0x0e
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/device.c:device_bonding_failed() 状态 14
12 月 17 日 07:36:15 bluetoothd[368]: ../bluez-5.50/src/adapter.c:resume_discovery()
12 月 17 日 07:36:36 bluetoothd[368]:../bluez-5.50/src/agent.c:agent_disconnect() 代理:1.49 已断开连接
12 月 17 日 07:36:36 bluetoothd[368]: ../bluez-5.50/src/agent.c:remove_default_agent() 默认代理已清除
12 月 17 日 07:36:36 bluetoothd[368]:../bluez-5.50/src/agent.c:agent_destroy() 代理:1.49
12 月 17 日 07:36:36 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_unref() 0xfd1000: ref=0
12 月 17 日 07:36:37 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_ref() 0xfd2808: ref=1
12 月 17 日 07:36:37 蓝牙 [368]:../bluez-5.50/src/agent.c:register_agent() 代理:1.51
12 月 17 日 07:36:37 蓝牙 [368]:../bluez-5.50/src/agent.c:unregister_agent() 代理:1.51
12 月 17 日 07:36:37 bluetoothd[368]:../bluez-5.50/src/agent.c:agent_disconnect() 代理:1.51 已断开连接
12 月 17 日 07:36:37 蓝牙 [368]:../bluez-5.50/src/agent.c:agent_destroy() 代理:1.51
12 月 17 日 07:36:37 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_unref() 0xfd2808: ref=0
============= 第二次连接:此设备在连接后无意中与应用系统取消配对 ====================== ==============
12 月 17 日 07:36:37 bluetoothd[368]: ../bluez-5.50/src/agent.c:agent_ref() 0xfd2808: ref=1
12 月 17 日 07:36:37 蓝牙 [368]:../bluez-5.50/src/agent.c:register_agent() 代理:1.51
12 月 17 日 07:36:37 bluetoothd[368]:../bluez-5.50/src/agent.c:add_default_agent() 默认代理设置为:1.51 /org/bluez/agent
12 月 17 日 07:36:42 bluetoothd[368]: ../bluez-5.50/src/adapter.c:connected_callback() hci0 device 4D:EE:4F:F1:6F:FD connected eir_len 0
12 月 17 日 07:36:42 bluetoothd[368]: ../bluez-5.50/src/device.c:device_create() dst 4D:EE:4F:F1:6F:FD
12 月 17 日 07:36:42 bluetoothd[368]: ../bluez-5.50/src/device.c:device_new() 地址 4D:EE:4F:F1:6F:FD
12 月 17 日 07:36:42 bluetoothd[368]: ../bluez-5.50/src/device.c:device_new() 创建设备 /org/bluez/hci0/dev_4D_EE_4F_F1_6F_FD
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/adapter.c:dev_disconnected() 设备 4D:EE:4F:F1:6F:FD 已断开连接,原因 3
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/adapter.c:adapter_remove_connection()
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/adapter.c:adapter_remove_connection() 删除临时设备 /org/bluez/hci0/dev_4D_EE_4F_F1_6F_FD
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/device.c:device_remove() 删除设备 /org/bluez/hci0/dev_4D_EE_4F_F1_6F_FD
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/device.c:btd_device_unref() 释放设备 /org/bluez/hci0/dev_4D_EE_4F_F1_6F_FD
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/device.c:device_free() 0xff3058
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/plugins/policy.c:disconnect_cb() 原因 3
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 4D:EE:4F:F1:6F:FD 类型 2 状态 0xe
12 月 17 日 07:36:43 bluetoothd[368]: ../bluez-5.50/src/adapter.c:resume_discovery()
解决方案
推荐阅读
- swift - 离开增强现实 ViewController 时,按钮在设备旋转之前不会检测到触摸
- python - python将日期转换为日期整数
- php - 图片上的链接在手机上不起作用
- excel - 如何解决 CATIA 宏中的运行时错误 438?
- java - 矩阵乘法 Big O 表示法
- c++ - 我的 Eclipse CDT 项目中有一个图像文件。如何在我的代码中引用它,以便协作者在运行代码时可以使用它?
- c - NULL 替代 C 语言 99 标准中的双精度数
- cmake - CMAKE - find_library find_path find_file 都不起作用
- css - flexbox 宽度不随换行列调整
- assembly - How do I efficiently do signed comparisons on the 8080?