임베디드 Linux 시스템(5.10.24)을 개발 중인데 시스템에 WIFI+BT 컨트롤러가 있습니다.
내 시스템에 Bluez5-5.54를 구축하고 설치했으며 BLE 연결을 테스트하기 위해 BLE 프린터를 연결하고 싶습니다.
, , 및 명령을 bluetoothctl
실행하여 프린터의 MAC 주소를 얻을 수 있었고, 그런 다음 및 를 시도했지만 두 명령 이 모두 실패했습니다.power on
scan on
scan off
pair
connect
커널 로그인이 드라이버를 로드합니다.
[ 70.181414] ---Forced switching Host mode!
[ 70.910063] usb 1-1: new high-speed USB device number 2 using dwc2
[ 71.160557] usb 1-1: New USB device found, idVendor=0bda, idProduct=d723, bcdDevice= 2.00
[ 71.169025] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 71.176450] usb 1-1: Product: 802.11n WLAN Adapter
[ 71.181429] usb 1-1: Manufacturer: Realtek
[ 71.185681] usb 1-1: SerialNumber: 00e04c000001
[ 71.191108] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNumber 0
[ 71.198765] rtk_btusb: btusb_probe can_wakeup 1, may wakeup 0
[ 71.204738] rtk_btusb: patch_add
[ 71.208072] rtk_btusb: auto suspend is disabled
[ 71.212790] rtk_btusb: pid = 0xd723
[ 71.216398] rtk_btusb: patch_add: Reset gEVersion to 0xff
[ 71.222029] rtk_btusb: set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
[ 71.229240] rtk_btusb: btusb_probe: done
[ 71.233653] rtk_btusb: btusb_open start
[ 71.237630] rtk_btusb: btusb_open hdev->promisc ==0
[ 71.242731] rtk_btusb: download_patch start
[ 71.247057] rtk_btusb: chip type value: 0x71
[ 71.251506] rtk_btusb: HCI reset.
[ 71.264497] rtk_btusb: read_ver_rsp->lmp_subver = 0x8723
[ 71.270004] rtk_btusb: read_ver_rsp->hci_rev = 0xd
[ 71.274998] rtk_btusb: patch_entry->lmp_sub = 0x8723
[ 71.280173] rtk_btusb: load_firmware start
[ 71.284411] rtk_btusb: lmp_version = 0x8723
[ 71.288732] rtk_btusb: config filename rtl8723du_config
[ 71.295693] rtk_btusb: no bdaddr file /opt/bdaddr
[ 71.300582] rtk_btusb: Origin cfg len 22
[ 71.304643] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00
[ 71.311462] rtk_btusb: 01 fa 8f 00 01 bf
[ 71.315542] rtk_btusb: New cfg len 22
[ 71.319350] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00
[ 71.326207] rtk_btusb: 01 fa 8f 00 01 bf
[ 71.330314] rtk_btusb: fw name is rtl8723du_fw
[ 71.341712] rtk_btusb: This is not 8723a, use new patch style!
[ 71.347755] rtk_btusb: rtk_get_eversion: gEVersion 255
[ 71.354513] rtk_btusb: eversion->status = 0x0, eversion->version = 0x2
[ 71.361309] rtk_btusb: load_firmware: New gEVersion 2
[ 71.366540] rtk_btusb: rtk_get_fw_project_id: opcode 0, len 1, data 9
[ 71.373268] rtk_btusb: lmp_version is 8723, project_id is 8723, match!
[ 71.380049] rtk_btusb: fw_version = 0x82a82df4
[ 71.384644] rtk_btusb: number_of_total_patch = 3
[ 71.389411] rtk_btusb: chipID 3
[ 71.392687] rtk_btusb: patch_length 0x7e6c
[ 71.396927] rtk_btusb: start_offset 0x00004940
[ 71.401554] rtk_btusb: Svn version: 24645
[ 71.405972] rtk_btusb: Coexistence: BTCOEX_20210106-3b3b
[ 71.411500] rtk_btusb: buf_len = 0x7e82
[ 71.415513] rtk_btusb: fw: exists, config file: exists
[ 71.420861] rtk_btusb: load_firmware done
[ 71.425022] rtk_btusb: download_data start
[ 71.540411] dwc2 13500000.otg: dwc2_hc_chhltd_intr_dma: Channel 1 - ChHltd set, but reason is unknown
[ 71.549945] dwc2 13500000.otg: hcint 0x00000002, intsts 0x06000029
[ 71.556338] dwc2 13500000.otg: dwc2_update_urb_state_abn(): trimming xfer length
[ 71.564078] ====>_BlockWrite 81 i:0
[ 71.567746] ====>_WriteFW 160
[ 71.571909] dwc2 13500000.otg: dwc2_hc_chhltd_intr_dma: Channel 2 - ChHltd set, but reason is unknown
[ 71.581451] dwc2 13500000.otg: hcint 0x00000002, intsts 0x04000029
[ 71.587833] dwc2 13500000.otg: dwc2_update_urb_state_abn(): trimming xfer length
[ 71.595582] ====>_BlockWrite 81 i:4
[ 71.599256] ====>_WriteFW 160
[ 71.745490] rtk_btusb: download_data done
[ 71.749663] rtk_btusb: HCI reset.
[ 71.762479] rtk_btusb: read_ver_rsp->lmp_subver = 0x2df4
[ 71.767971] rtk_btusb: read_ver_rsp->hci_rev = 0x82a8
[ 71.773226] rtk_btusb: patch_entry->lmp_sub = 0x8723
[ 71.778359] rtk_btusb: Rtk patch end 0
[ 71.782384] rtk_btusb: btusb_open set HCI_RUNNING
[ 71.787283] rtk_btcoex: Open BTCOEX
[ 71.790922] rtk_btusb: btusb_open end
[ 71.797497] rtk_btcoex: BTCOEX hci_rev 0x82a8
[ 71.802187] rtk_btcoex: BTCOEX lmp_subver 0x2df4
[ 71.822523] rtk_btusb: btusb_notify: hci0 evt 3
[ 73.920072] rtk_btusb: btusb_flush add delay
[ 73.934988] rtk_btusb: btusb_close
[ 73.948960] rtk_btcoex: Close BTCOEX
[ 73.952693] rtk_btcoex: -x
.....
이것은 bluetoothctl
내가 얻은 로그입니다.
[bluetooth]# show
Controller YY:YY:YY:3B:F6:7B (public)
Name: BlueZ 5.54
Alias: BlueZ 5.54
Class: 0x00000000
Powered: no
Discoverable: no
DiscoverableTimeout: 0x000000b4
Pairable: yes
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0536
Discovering: no
Advertising Features:
ActiveInstances: 0x00
SupportedInstances: 0x05
SupportedIncludes: tx-power
SupportedIncludes: appearance
SupportedIncludes: local-name
[bluetooth]# info xx:xx:xx:05:BF:6C
Device xx:xx:xx:05:BF:6C (public)
Name: printer-bf6c
Alias: printer-bf6c
Class: 0x00040680
Icon: printer
Paired: no
Trusted: no
Blocked: no
Connected: no
LegacyPairing: no
UUID: Vendor specific (ffcacade-afde-cade-defa-cade00000000)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: L2CAP (00000100-0000-1000-8000-00805f9b34fb)
UUID: SDP (00000001-0000-1000-8000-00805f9b34fb)
UUID: Serial Port (00001101-0000-1000-8000-00805f9b34fb)
UUID: RFCOMM (00000003-0000-1000-8000-00805f9b34fb)
ManufacturerData Key: 0x0000
ManufacturerData Value:
xx xx xx 05 bf 6c ..z..l
[bluetooth]# connect xx:xx:xx:05:BF:6C
Attempting to connect to xx:xx:xx:05:BF:6C
[CHG] Device xx:xx:xx:05:BF:6C Connected: yes
[CHG] Device xx:xx:xx:05:BF:6C ServicesResolved: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device xx:xx:xx:05:BF:6C ServicesResolved: no
[CHG] Device xx:xx:xx:05:BF:6C Connected: no
Device xx:xx:xx:05:BF:6C (public)
Name: printer-bf6c
Alias: printer-bf6c
Class: 0x00040680
Icon: printer
Paired: no
Trusted: no
Blocked: no
Connected: no
LegacyPairing: yes
UUID: Serial Port (00001101-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
Modalias: usb:v05ACp0239d0644
ManufacturerData Key: 0x0000
ManufacturerData Value:
xx xx xx 05 bf 6c ..z..l
연결 시 표시되는 커널 로그
[ 388.391092] rtk_btusb: btusb_notify: hci0 evt 1
[ 388.392517] rtk_btcoex: hci create connection, start paging
[ 389.797526] rtk_btcoex: connected, handle 0002, status 0x00
[ 389.797540] rtk_btcoex: Page success
[ 389.822942] rtk_btcoex: l2cap op 2, len 16, out 1
[ 389.822987] rtk_btcoex: TX l2cap conn req, hndl 0x0002, PSM 0x0001, scid 0x0040
[ 389.822995] rtk_btcoex: PSM(0x0001) do not need parse
[ 389.826726] rtk_btcoex: l2cap op 3, len 20, out 0
[ 389.826772] rtk_btcoex: RX l2cap conn rsp, hndl 0x0002, dcid 0x0050, scid 0x0040, result 0x0001
[ 389.925401] rtk_btcoex: l2cap op 3, len 20, out 0
[ 389.925473] rtk_btcoex: RX l2cap conn rsp, hndl 0x0002, dcid 0x0050, scid 0x0040, result 0x0000
[ 392.443287] rtk_btcoex: l2cap op 6, len 16, out 1
[ 392.443361] rtk_btcoex: TX l2cap disconn req, hndl 0x0002, dcid 0x0050, scid 0x0040
[ 392.443374] rtk_btcoex: handle_l2cap_discon_req: handle 0x0002, dcid 0x0050, scid 0x0040, dir 1
[ 394.480081] rtk_btcoex: HCI Disconnect, handle 0002, reason 0x13
[ 394.557527] rtk_btcoex: disconn cmpl evt: status 0x00, handle 0002, reason 0x16
[ 394.557539] rtk_btcoex: process disconn complete event.
[ 394.630054] rtk_btusb: btusb_notify: hci0 evt 2
다음과 같은 이유로 HCI 연결이 끊어졌습니다 0x13
.
connect 명령 후 info
명령은 프린터의 UUID가 명령 전과 다르다는 것을 보여줍니다 connect
.
구글링해 보니 0x13
호스트와 프린터 사이에 불일치가 있는 것 같습니다.
이 오류가 발생하는 이유와 해결 방법을 모르겠습니다.
업데이트된 Bluetooth 디버그 로그
을 실행하면 pair XX:XX:XX:05:BF:6C
bluetoothd는 먼저 프린터에 연결한 다음 연결을 끊는 것을 보여줍니다.
[bluetooth]# info XX:XX:XX:05:BF:6C
Device XX:XX:XX:05:BF:6C (public)
Name: printer-bf6c
Alias: printer-bf6c
Class: 0x00040680
Icon: printer
Paired: no
Trusted: no
Blocked: no
Connected: no
LegacyPairing: yes
[bluetooth]# trust XX:XX:XX:05:BF:6C
[bluetooth]# bluetoothd[1153]: src/device.c:btd_device_set_trusted() trusted 1
[CHG] Device XX:XX:XX:05:BF:6C Trusted: yes
Changing XX:XX:XX:05:BF:6C trust succeeded
[bluetooth]# pair XX:XX:XX:05:BF:6C
Attempting to pair with XX:XX:XX:05:BF:6C
bluetoothd[1153]: src/device.c:btd_device_set_temporary() temporary 0
bluetoothd[1153]: src/agent.c:agent_ref() 0x1730968: ref=2
bluetoothd[1153]: src/device.c:bonding_request_new() Requesting bonding for XX:XX:XX:05:BF:6C
bluetoothd[1153]: src/agent.c:agent_ref() 0x1730968: ref=3
bluetoothd[1153]: src/agent.c:agent_unref() 0x1730968: ref=2
bluetoothd[1153]: src/adapter.c:suspend_discovery()
bluetoothd[1153]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr XX:XX:XX:05:BF:6C type 0 io_cap 0x04
bluetoothd[1153]: src/adapter.c:add_whitelist_complete() XX:XX:XX:05:BF:6C added to kernel whitelist
[bluetooth]# bluetoothd[1153]: src/adapter.c:connected_callback() hci0 device XX:XX:XX:05:BF:6C connected eir_len 19
[CHG] Device XX:XX:XX:05:BF:6C Connected: yes
[printer-bf6c]# bluetoothd[1153]: src/adapter.c:new_link_key_callback() hci0 new key for XX:XX:XX:05:BF:6C type 4 pin_len 0 store_hint 1
bluetoothd[1153]: src/device.c:device_set_bonded()
bluetoothd[1153]: src/device.c:device_bonding_complete() bonding 0x1746f98 status 0x00
bluetoothd[1153]: src/device.c:device_bonding_complete() Proceeding with service discovery
bluetoothd[1153]: src/agent.c:agent_unref() 0x1730968: ref=1
bluetoothd[1153]: src/adapter.c:resume_discovery()
bluetoothd[1153]: src/adapter.c:pair_device_complete() Success (0x00)
bluetoothd[1153]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr XX:XX:XX:05:BF:6C type 0 status 0x0
bluetoothd[1153]: src/device.c:device_bonding_complete() bonding (nil) status 0x00
bluetoothd[1153]: src/adapter.c:resume_discovery()
[CHG] Device XX:XX:XX:05:BF:6C Modalias: usb:v05ACp0239d0644
[printer-bf6c]# bluetoothd[1153]: src/device.c:device_probe_profiles() Probing profiles for device XX:XX:XX:05:BF:6C
bluetoothd[1153]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_02_00_7A_05_BF_6C err 0
[CHG] Device XX:XX:XX:05:BF:6C UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:05:BF:6C UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:05:BF:6C ServicesResolved: yes
[CHG] Device XX:XX:XX:05:BF:6C Paired: yes
Pairing successful
[printer-bf6c]# bluetoothd[1153]: src/adapter.c:dev_disconnected() Device XX:XX:XX:05:BF:6C disconnected, reason 2
bluetoothd[1153]: src/adapter.c:adapter_remove_connection()
bluetoothd[1153]: plugins/policy.c:disconnect_cb() reason 2
bluetoothd[1153]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr XX:XX:XX:05:BF:6C type 0 status 0xe
bluetoothd[1153]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[1153]: src/device.c:device_bonding_failed() status 14
bluetoothd[1153]: src/adapter.c:resume_discovery()
[CHG] Device XX:XX:XX:05:BF:6C ServicesResolved: no
[CHG] Device XX:XX:XX:05:BF:6C Connected: no
[bluetooth]# info XX:XX:XX:05:BF:6C
Device XX:XX:XX:05:BF:6C (public)
Name: printer-bf6c
Alias: printer-bf6c
Class: 0x00040680
Icon: printer
Paired: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: yes
UUID: Serial Port (00001101-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
Modalias: usb:v05ACp0239d0644
[bluetooth]# quit
그런 다음 rfcomm
명령을 사용하여 프린터를 바인딩하고 echo XXXXXX > /dev/rfcomm0
텍스트를 인쇄해 봅니다.
다음은 명령과 로그입니다.
~# rfcomm show /dev/rfcomm0
rfcomm0: XX:XX:XX:05:BF:6C channel 1 closed
~# rfcomm release /dev/rfcomm0
~# rfcomm bind 0 XX:XX:XX:05:BF:6C
~# rfcomm show /dev/rfcomm0
rfcomm0: XX:XX:XX:05:BF:6C channel 1 clean
~# rfcomm show /dev/rfcomm0
rfcomm0: XX:XX:XX:05:BF:6C channel 1 clean
~# echo "XXXXXX " > /dev/rfcomm0
bluetoothd[1153]: src/adapter.c:connected_callback() hci0 device XX:XX:XX:05:BF:6C connected eir_len 19
bluetoothd[1153]: src/adapter.c:dev_disconnected() Device XX:XX:XX:05:BF:6C disconnected, reason 3
bluetoothd[1153]: src/adapter.c:adapter_remove_connection()
bluetoothd[1153]: plugins/policy.c:disconnect_cb() reason 3
bluetoothd[1153]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr XX:XX:XX:05:BF:6C type 0 status 0xe
bluetoothd[1153]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[1153]: src/device.c:device_bonding_failed() status 14
bluetoothd[1153]: src/adapter.c:resume_discovery()
그리고 아무것도 인쇄되지 않습니다!