军事研究员 2024-04-17 19:21 采纳率: 98.6%
浏览 87
已结题

linux下蓝牙开发:无法连接-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

  • 写回答

6条回答 默认 最新

  • 码农阿豪@新空间 优质创作者: Java、后端开发技术领域 2024-04-17 19:21
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    此为一段蓝牙设备连接的日志信息,从日志中看到已经成功进行了配对和绑定,但是在连接网络时出现了问题,出现了错误状态码为0的情况。需要进一步排查网络连接的问题。 参考代码:
    bluetoothctl
    [bluetooth]# power on 
    [bluetooth]# agent on 
    [bluetooth]# scan on 
    [bluetooth]# pair D8:A4:91:AB:46:49
    [bluetooth]# trust D8:A4:91:AB:46:49
    [bluetooth]# connect D8:A4:91:AB:46:49
    

    需要注意的是,在具体开发中,需要根据实际蓝牙设备的信息来进行替换相应的地址等信息。同时,在连接网络时可能需要进行更多的操作,如配置网络参数、启动网络服务等,需要结合具体网络环境进行判断和实现。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

问题事件

  • 系统已结题 9月19日
  • 已采纳回答 9月11日
  • 修改了问题 7月4日
  • 修改了问题 4月17日
  • 展开全部