透明水晶 2024-04-17 19:21 采纳率: 96.8%
浏览 18

inux下蓝牙开发:无法连接-20240417

linux下蓝牙开发:无法连接

img


[bluetooth]# pair D8:A4:91:AB:46:49      
Attempting to pair with D8:A4:91:AB:46:49
bluetoothd[1006]: src/device.c:btd_device_set_temporary() temporary 0
bluetoothd[1006]: src/agent.c:agent_ref() 0xbf6e0: ref=2
bluetoothd[1006]: src/device.c:bonding_request_new() Requesting bonding for D8:A4:91:AB:46:49
bluetoothd[1006]: src/agent.c:agent_ref() 0xbf6e0: ref=3
bluetoothd[1006]: src/agent.c:agent_unref() 0xbf6e0: ref=2
bluetoothd[1006]: src/adapter.c:suspend_discovery() 
bluetoothd[1006]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D8:A4:91:AB:46:49 type 0 io_cap 0x04
bluetoothd[1006]: src/adapter.c:add_whitelist_complete() D8:A4:91:AB:46:49 added to kernel whitelist
[bluetooth]# bluetoothd[1006]: src/adapter.c:connected_callback() hci0 device D8:A4:91:AB:46:49 connected eir_len 9
[CHG] Device D8:A4:91:AB:46:49 Connected: yes
[dafeige]# bluetoothd[1006]: src/adapter.c:user_confirm_request_callback() hci0 D8:A4:91:AB:46:49 confirm_hint 0
bluetoothd[1006]: src/device.c:new_auth() Requesting agent authentication for D8:A4:91:AB:46:49
bluetoothd[1006]: src/agent.c:agent_ref() 0xbf6e0: ref=3
bluetoothd[1006]: src/agent.c:agent_request_confirmation() Calling Agent.RequestConfirmation: name=:1.2, path=/org/bluez/agent, passkey=965006
Request confirmation  
[agent] Confirm passkey 965006 (yes/no): yes
[dafeige]# bluetoothd[1006]: src/agent.c:agent_ref() 0xbf6e0: ref=4
bluetoothd[1006]: src/adapter.c:btd_adapter_confirm_reply() hci0 addr D8:A4:91:AB:46:49 success 1
bluetoothd[1006]: src/agent.c:agent_unref() 0xbf6e0: ref=3
bluetoothd[1006]: src/agent.c:agent_unref() 0xbf6e0: ref=2
bluetoothd[1006]: src/adapter.c:new_link_key_callback() hci0 new key for D8:A4:91:AB:46:49 type 5 pin_len 0 store_hint 1
bluetoothd[1006]: src/device.c:device_set_bonded() 
bluetoothd[1006]: src/device.c:device_bonding_complete() bonding 0xb5a98 status 0x00
bluetoothd[1006]: src/device.c:device_bonding_complete() Proceeding with service discovery
bluetoothd[1006]: src/agent.c:agent_unref() 0xbf6e0: ref=1
bluetoothd[1006]: src/adapter.c:resume_discovery() 
bluetoothd[1006]: src/adapter.c:pair_device_complete() Success (0x00)
bluetoothd[1006]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D8:A4:91:AB:46:49 type 0 status 0x0
bluetoothd[1006]: src/device.c:device_bonding_complete() bonding (nil) status 0x00
bluetoothd[1006]: src/adapter.c:resume_discovery() 
bluetoothd[1006]: src/device.c:device_probe_profiles() Probing profiles for device D8:A4:91:AB:46:49
bluetoothd[1006]: profiles/gap/gas.c:gap_probe() GAP profile probe (D8:A4:91:AB:46:49)
bluetoothd[1006]: src/service.c:change_state() 0xb5b50: device D8:A4:91:AB:46:49 profile gap-profile state changed: unavailable -> disconnected (0)
bluetoothd[1006]: profiles/network/connection.c:connection_register() /org/bluez/hci0/dev_D8_A4_91_AB_46_49 id 4373
bluetoothd[1006]: profiles/network/connection.c:create_peer() Registered interface org.bluez.Network1 on path /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: src/service.c:btd_service_ref() 0xe6d30: ref=2
bluetoothd[1006]: profiles/network/connection.c:connection_register() id 4373 registered
bluetoothd[1006]: src/service.c:change_state() 0xe6d30: device D8:A4:91:AB:46:49 profile network-panu state changed: unavailable -> disconnected (0)
bluetoothd[1006]: profiles/network/connection.c:connection_register() /org/bluez/hci0/dev_D8_A4_91_AB_46_49 id 4374
bluetoothd[1006]: src/service.c:btd_service_ref() 0xbe370: ref=2
bluetoothd[1006]: profiles/network/connection.c:connection_register() id 4374 registered
bluetoothd[1006]: src/service.c:change_state() 0xbe370: device D8:A4:91:AB:46:49 profile network-nap state changed: unavailable -> disconnected (0)
bluetoothd[1006]: profiles/audio/avrcp.c:avrcp_target_probe() path /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: profiles/audio/control.c:control_init() Registered interface org.bluez.MediaControl1 on path /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: src/service.c:btd_service_ref() 0xe6c48: ref=2
bluetoothd[1006]: src/service.c:change_state() 0xe6c48: device D8:A4:91:AB:46:49 profile audio-avrcp-target state changed: unavailable -> disconnected (0)
bluetoothd[1006]: profiles/audio/a2dp.c:a2dp_source_probe() path /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: profiles/audio/source.c:source_init() /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: src/service.c:btd_service_ref() 0xb9b60: ref=2
bluetoothd[1006]: src/service.c:change_state() 0xb9b60: device D8:A4:91:AB:46:49 profile a2dp-source state changed: unavailable -> disconnected (0)
bluetoothd[1006]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_D8_A4_91_AB_46_49 err 0
[CHG] Device D8:A4:91:AB:46:49 Modalias: bluetooth:v010Fp107Ed1436
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000046a-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000fdd1-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 0000fe35-0000-1000-8000-00805f9b34fb
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 11c8b310-80e4-4276-afc0-f81590b2177f
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 8ce255c0-200a-11e0-ac64-0800200c9a66
[CHG] Device D8:A4:91:AB:46:49 UUIDs: 9664aa26-d76c-43ad-9775-d310f253a408
[CHG] Device D8:A4:91:AB:46:49 ServicesResolved: yes
[CHG] Device D8:A4:91:AB:46:49 Paired: yes
Pairing successful    
[dafeige]# bluetoothd[1006]: src/adapter.c:dev_disconnected() Device D8:A4:91:AB:46:49 disconnected, reason 3
bluetoothd[1006]: src/adapter.c:adapter_remove_connection() 
bluetoothd[1006]: plugins/policy.c:disconnect_cb() reason 3
bluetoothd[1006]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D8:A4:91:AB:46:49 type 0 status 0xe
bluetoothd[1006]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[1006]: src/device.c:device_bonding_failed() status 14
bluetoothd[1006]: src/adapter.c:resume_discovery() 
[CHG] Device D8:A4:91:AB:46:49 ServicesResolved: no
[CHG] Device D8:A4:91:AB:46:49 Connected: no
[bluetooth]# 

问题2

img


[bluetooth]# connect D8:A4:91:AB:46:49
Attempting to connect to D8:A4:91:AB:46:49
bluetoothd[1006]: src/device.c:connect_profiles() /org/bluez/hci0/dev_D8_A4_91_AB_46_49 (all), client :1.3
bluetoothd[1006]: profiles/audio/a2dp.c:a2dp_source_connect() path /org/bluez/hci0/dev_D8_A4_91_AB_46_49
bluetoothd[1006]: a2dp-source profile connect failed for D8:A4:91:AB:46:49: Protocol not available
Failed to connect: org.bluez.Error.Failed
[bluetooth]# bluetoothd[1006]: src/adapter.c:remove_temp_devices() /org/bluez/hci0
bluetoothd[1006]: src/device.c:device_remove() Removing device /org/bluez/hci0/dev_4C_CC_4C_20_CC_EE
bluetoothd[1006]: src/device.c:btd_device_unref() Freeing device /org/bluez/hci0/dev_4C_CC_4C_20_CC_EE
bluetoothd[1006]: src/device.c:device_free() 0xbf4d8
bluetoothd[1006]: src/device.c:device_remove() Removing device /org/bluez/hci0/dev_5D_6D_27_E4_72_82
[DEL] Device 4C:CC:4C:20:CC:EE 4C-CC-4C-20-CC-EE
[bluetooth]# bluetoothd[1006]: src/device.c:btd_device_unref() Freeing device /org/bluez/hci0/dev_5D_6D_27_E4_72_82
bluetoothd[1006]: src/device.c:device_free() 0xbfef8
[DEL] Device 5D:6D:27:E4:72:82 5D-6D-27-E4-72-82

  • 写回答

5条回答 默认 最新

  • 专家-赤兔[在线] 全栈领域优质创作者 2024-04-17 19:21
    关注

    引自免费微信小程序:皆我百晓生

    根据您提供的日志信息,似乎你在尝试与一个蓝牙设备(地址为D8:A4:91:AB:46:49)进行配对并建立连接,但是在成功配对后不久,设备就断开了连接,并且在后续的连接尝试中遇到了问题。错误码0xe通常表示蓝牙操作被拒绝。

    以下是一些可能的解决步骤:

    1. 检查蓝牙服务状态: 确保蓝牙服务正在运行并且没有异常。可以通过运行systemctl status bluetooth命令来查看。

    2. 重启蓝牙服务: 如果蓝牙服务有问题,可以尝试重启它:

      sudo systemctl restart bluetooth
      
    3. 更新蓝牙驱动和内核模块: 更新系统中的蓝牙驱动和内核模块可能会修复一些兼容性问题。首先更新软件包:

      sudo apt-get update
      sudo apt-get upgrade bluez libbluetooth-dev
      

      如果是基于Debian或Ubuntu系统的,还需要安装最新的内核更新:

      sudo apt-get install linux-generic
      
    4. 检查蓝牙设备兼容性和固件: 确认您的Linux系统支持目标蓝牙设备的蓝牙版本。此外,确保蓝牙设备的固件是最新的。

    5. 排查配对问题: 日志显示配对过程中需要输入确认码,这表明可能需要用户交互。确保在配对时正确提供了所需的确认信息。如果问题依然存在,尝试删除已有的配对记录然后重新配对:

      sudo rm /var/lib/bluetooth/<your MAC address>/info
      
    6. 检查设备设置: 在蓝牙设备端,确保其蓝牙功能开启并且允许被发现。同时,检查设备的配对模式是否正确设置。

    7. 权限问题: 检查用户账户是否有足够的权限来操作蓝牙。如果使用的是非root用户,可以尝试以管理员权限运行蓝牙命令。

    8. 网络配置: 针对日志中的network profiles(如network-panu、network-nap),确保您的系统配置支持这些网络配置协议。

    9. 蓝牙日志分析: 分析蓝牙日志可以帮助定位更具体的问题。注意任何异常输出,比如错误代码或失败原因。如果日志中有不明确的部分,可以在蓝牙开发者社区或者Stack Overflow等论坛寻求帮助。

    10. 第三方应用: 如果是在特定的应用程序中遇到问题,试着禁用或卸载可能导致冲突的其他蓝牙应用程序,然后再试。

    11. 系统故障排查: 如果以上所有方法都无效,可能是系统层面的问题,考虑备份数据后重装系统或者尝试不同的Linux发行版。

    如果问题仍然存在,可能需要更多的调试信息来确定具体的故障点。如果你能提供更多的上下文,例如设备型号、使用的Linux发行版以及是否有任何特定应用程序引发这个问题,我可以提供更精确的帮助。

    评论 编辑记录

报告相同问题?

问题事件

  • 修改了问题 4月17日
  • 创建了问题 4月17日

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致