linux 蓝牙命令 |
您所在的位置:网站首页 › linux查看设备状态 › linux 蓝牙命令 |
本文先收集基本的蓝牙命令,而后明了linux中蓝牙子系统的结构。后续文章再针对性细化。 目录 目录 hciconfig 默认参数为查看蓝牙控制器设备: 控制器的开关 hcitool 查询设备 扫描设备 bluetoothctl 查询当前的设备 配对设备 移除设备 问题 hciconfigHost Controller Interface 默认参数为查看蓝牙控制器设备:hci0: Type: Primary Bus: USB BD Address: 2C:33:7A:F4:DC:C2 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING PSCAN ISCAN RX bytes:4470 acl:1 sco:0 events:319 errors:0 TX bytes:39127 acl:0 sco:0 commands:294 errors:0 上面的UP 和RUNNING,看起来和网口比较类似,即即有物理链接,又配置了设备地址。 控制器的开关hciconfig hci0 down sudo hciconfig hci0: Type: Primary Bus: USB BD Address: 2C:33:7A:F4:DC:C2 ACL MTU: 1021:8 SCO MTU: 64:1 DOWN RX bytes:4470 acl:1 sco:0 events:319 errors:0 TX bytes:39127 acl:0 sco:0 commands:294 errors:0 hcitoolhcitool - HCI Tool ver 5.50 查询设备包括本地和远端设备,发起设备扫描 查询设备sudo hcitool dev 本地设备,可以看出和上面命令查到一样的设备,即蓝牙控制器 Devices: hci0 2C:33:7A:F4:DC:C2sudo hcitool inq 这个查询远端设备,虽然物理上有设备,但需要先进行扫描,然后才能看到。 Inquiring ... 扫描设备sudo hciconfig hci0 iscan $ hcitool scan Scanning ... 48:59:A4:BB:7A:08 ZTE Blade A7s $ hciconfig hci0: Type: Primary Bus: USB BD Address: 2C:33:7A:F4:DC:C2 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING PSCAN RX bytes:5815 acl:1 sco:0 events:408 errors:0 TX bytes:40065 acl:0 sco:0 commands:364 errors:0以下两种扫描方式的差异是什么?在笔记本和手机蓝牙进行链接时,改配不同的scan参数,扫描结果有些差异。有时候扫描不到设备,将手机蓝牙重新关开,则可以扫描到。 iscan Enable Inquiry scan pscan Enable Page scan 采用iscan 时,内核dmesg报错: Bluetooth: hci0: inquiry failed: status 0x12 获取对端设备信息 sudo hcitool info 48:59:A4:BB:7A:08 ( ZTE Blade A7s的地址) Requesting information ... BD Address: 48:59:A4:BB:7A:08 OUI Company: zte corporation (48-59-A4) Device Name: ZTE Blade A7s LMP Version: 5.0 (0x9) LMP Subversion: 0x0 Manufacturer: MediaTek, Inc. (70) Features page 0: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87 Features page 1: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Features page 2: 0x05 0x03 0x00 0x00 0x00 0x00 0x00 0x00 bluetoothctl 查询当前的设备sudo bluetoothctl devices Device 44:16:2F:9C:E6:11 44-16-2F-9C-E6-11 Device 76:8C:C7:2D:46:32 76-8C-C7-2D-46-32 Device 43:E2:DC:4B:D4:32 43-E2-DC-4B-D4-32 Device 52:65:DA:D4:6B:F9 52-65-DA-D4-6B-F9 Device 48:F4:92:D8:60:43 48-F4-92-D8-60-43 Device 4D:F5:AA:77:A7:29 4D-F5-AA-77-A7-29 Device 1C:B7:96:20:00:03 POT-AL00a Device D8:1E:DD:09:C8:10 OPPO A9x Device 39:EF:03:0B:CA:9C EDIFIER BLEDevice 48:59:A4:BB:7A:08 ZTE Blade A7s 配对设备sudo bluetoothctl pair 48:59:A4:BB:7A:08 Attempting to pair with 48:59:A4:BB:7A:08 [CHG] Device 48:59:A4:BB:7A:08 Connected: yes [DEL] Device 39:EF:03:0B:CA:9C EDIFIER BLE [DEL] Device D8:1E:DD:09:C8:10 OPPO A9x [DEL] Device 1C:B7:96:20:00:03 POT-AL00a [DEL] Device 4D:F5:AA:77:A7:29 4D-F5-AA-77-A7-29 [DEL] Device 48:F4:92:D8:60:43 48-F4-92-D8-60-43 [DEL] Device 52:65:DA:D4:6B:F9 52-65-DA-D4-6B-F9 [DEL] Device 43:E2:DC:4B:D4:32 43-E2-DC-4B-D4-32 [DEL] Device 76:8C:C7:2D:46:32 76-8C-C7-2D-46-32 [DEL] Device 44:16:2F:9C:E6:11 44-16-2F-9C-E6-11Failed to pair: org.bluez.Error.AuthenticationFailed 在配对时在电脑测,必须在此弹出的窗口中点击“配对”,才能授权成功,则配对成功 sudo bluetoothctl pair 48:59:A4:BB:7A:08 Attempting to pair with 48:59:A4:BB:7A:08 [CHG] Device 48:59:A4:BB:7A:08 Connected: yes [CHG] Device 48:59:A4:BB:7A:08 Modalias: bluetooth:v0046p1200d1436 [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001105-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001112-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001115-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001116-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000112d-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001132-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001200-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001800-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 UUIDs: 00001801-0000-1000-8000-00805f9b34fb [CHG] Device 48:59:A4:BB:7A:08 ServicesResolved: yes [CHG] Device 48:59:A4:BB:7A:08 Paired: yes Pairing successful 再次配对,报错: $ sudo bluetoothctl pair 48:59:A4:BB:7A:08 Attempting to pair with 48:59:A4:BB:7A:08 Failed to pair: org.bluez.Error.AlreadyExists 配对和链接是两个不同的过程。 移除设备sudo bluetoothctl remove 48:59:A4:BB:7A:08 [CHG] Device 48:59:A4:BB:7A:08 ServicesResolved: no Device has been removed $ sudo bluetoothctl pair 48:59:A4:BB:7A:08 Device 48:59:A4:BB:7A:08 not available 此时报设备不可用,需要重新scan设备。 l2ping查看底层链路的联通性 sudo l2ping 48:59:A4:BB:7A:08 Ping: 48:59:A4:BB:7A:08 from 2C:33:7A:F4:DC:C2 (data size 44) ... 44 bytes from 48:59:A4:BB:7A:08 id 0 time 16.42ms 44 bytes from 48:59:A4:BB:7A:08 id 1 time 9.93ms 44 bytes from 48:59:A4:BB:7A:08 id 2 time 11.12ms 44 bytes from 48:59:A4:BB:7A:08 id 3 time 21.23mssudo l2ping 48:59:A4:BB:7A:07 Can't connect: Host is down 问题1. scan设备的流程是怎么样的?为什么必须手机侧把蓝牙关了再打开,在笔记本侧才能扫描到 2. 配对的流程?配置按钮时做了哪些操作? |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |