hciconfig
是一个用于配置和管理蓝牙HCI(Host Controller Interface)设备的命令行工具。它允许用户对蓝牙设备进行各种操作,如启用、禁用、重置设备,以及配置各种蓝牙参数。以下是 hciconfig
命令的详细用法和一些常用命令的解释:
[root@:/]# hciconfig -h
hciconfig - HCI device configuration utility
Usage:
hciconfig
hciconfig [-a] hciX [command ...]
Commands:
up Open and initialize HCI device
down Close HCI device
reset Reset HCI device
rstat Reset statistic counters
auth Enable Authentication
noauth Disable Authentication
encrypt Enable Encryption
noencrypt Disable Encryption
piscan Enable Page and Inquiry scan
noscan Disable scan
iscan Enable Inquiry scan
pscan Enable Page scan
ptype [type] Get/Set default packet type
lm [mode] Get/Set default link mode
lp [policy] Get/Set default link policy
name [name] Get/Set local name
class [class] Get/Set class of device
voice [voice] Get/Set voice setting
iac [iac] Get/Set inquiry access code
inqtpl [level] Get/Set inquiry transmit power level
inqmode [mode] Get/Set inquiry mode
inqdata [data] Get/Set inquiry data
inqtype [type] Get/Set inquiry scan type
inqparms [win:int] Get/Set inquiry scan window and interval
pageparms [win:int] Get/Set page scan window and interval
pageto [to] Get/Set page timeout
afhmode [mode] Get/Set AFH mode
sspmode [mode] Get/Set Simple Pairing Mode
aclmtu <mtu:pkt> Set ACL MTU and number of packets
scomtu <mtu:pkt> Set SCO MTU and number of packets
delkey <bdaddr> Delete link key from the device
oobdata Get local OOB data
commands Display supported commands
features Display device features
version Display version information
revision Display revision information
block <bdaddr> Add a device to the blacklist
unblock <bdaddr> Remove a device from the blacklist
lerandaddr <bdaddr> Set LE Random Address
leadv [type] Enable LE advertising
0 - Connectable undirected advertising (default)
3 - Non connectable undirected advertising
noleadv Disable LE advertising
lestates Display the supported LE states
基本用法
hciconfig [选项] hciX [命令 ...]
常用选项
-a
:显示所有蓝牙设备的详细信息。
常用命令
up
:打开并初始化HCI设备。down
:关闭HCI设备。reset
:重置HCI设备。rstat
:重置统计计数器。auth
:启用认证。noauth
:禁用认证。encrypt
:启用加密。noencrypt
:禁用加密。piscan
:启用Page和Inquiry扫描。noscan
:禁用扫描。iscan
:启用Inquiry扫描。pscan
:启用Page扫描。ptype [type]
:获取/设置默认数据包类型。lm [mode]
:获取/设置默认链路模式。lp [policy]
:获取/设置默认链路策略。name [name]
:获取/设置本地名称。class [class]
:获取/设置设备类。voice [voice]
:获取/设置语音设置。iac [iac]
:获取/设置Inquiry访问码。inqtpl [level]
:获取/设置Inquiry传输功率级别。inqmode [mode]
:获取/设置Inquiry模式。inqdata [data]
:获取/设置Inquiry数据。inqtype [type]
:获取/设置Inquiry扫描类型。inqparms [win:int]
:获取/设置Inquiry扫描窗口和间隔。pageparms [win:int]
:获取/设置Page扫描窗口和间隔。pageto [to]
:获取/设置Page超时。afhmode [mode]
:获取/设置AFH模式。sspmode [mode]
:获取/设置简单配对模式。aclmtu <mtu:pkt>
:设置ACL MTU和数据包数量。scomtu <mtu:pkt>
:设置SCO MTU和数据包数量。delkey <bdaddr>
:从设备中删除链接密钥。oobdata
:获取本地OOB数据。commands
:显示支持的命令。features
:显示设备特性。version
:显示版本信息。revision
:显示修订信息。block <bdaddr>
:将设备添加到黑名单。unblock <bdaddr>
:从黑名单中移除设备。lerandaddr <bdaddr>
:设置LE随机地址。leadv [type]
:启用LE广告。0
- 可连接无向广告(默认)3
- 不可连接无向广告
noleadv
:禁用LE广告。lestates
:显示支持的LE状态。
示例
- 显示所有蓝牙设备的详细信息:
hciconfig -a
[root@rockchip:~]# hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: 0C:D0:33:97:37:99 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:2433 acl:41 sco:0 events:101 errors:0
TX bytes:5846 acl:40 sco:0 commands:71 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: PERIPHERAL ACCEPT
Name: 'SCO_AUDIO1'
Class: 0x100414
Service Classes: Object Transfer
Device Class: Audio/Video, Loudspeaker
HCI Version: 4.2 (0x8) Revision: 0x10d
LMP Version: 4.2 (0x8) Subversion: 0x6119
Manufacturer: Broadcom Corporation (15)
-
启用并初始化HCI设备:
hciconfig hci0 up
-
关闭HCI设备:
hciconfig hci0 down
-
重置HCI设备:
hciconfig hci0 reset
-
启用Page和Inquiry扫描:
hciconfig hci0 piscan
-
设置本地名称:
hciconfig hci0 name "MyBluetoothDevice"
-
启用简单配对模式:
hciconfig hci0 sspmode 1