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 Set ACL MTU and number of packets scomtu Set SCO MTU and number of packets putkey Store link key on the device delkey Delete link key from the device oobdata Display local OOB data commands Display supported commands features Display de 00:A0:C6:FF:FF:FF vice features version Display version information revision Display revision information 1.我们首先看前两条命令:up和down以及reset命令 我们首先输入hciconfig hci0 down 然后输入hciconfig 输出hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 DOWN RX bytes:768 acl:0 sco:0 events:35 errors:0 TX bytes:648 acl:0 sco:0 commands:34 errors:0 我们看到蓝牙设备的状态已经是down. 然后输入hciconfig hci0 up hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 UP RUNNING PSCAN ISCAN RX bytes:762 acl:0 sco:0 events:34 errors:0 TX bytes:645 acl:0 sco:0 commands:33 errors:0 我们首先输入命令hciconfig hci0 down hciconfig hci0 reset 输出的结果是hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 UP RUNNING PSCAN ISCAN RX bytes:3066 acl:0 sco:0 events:139 errors:0 TX bytes:2589 acl:0 sco:0 commands:135 errors:0 我们看到设备已经重设。 2。接下来我们来看下面的两个命令参数,auth和noauth 我们首先输入hciconfig hci0 auth 然后使用另外一台蓝牙B设备向本地设备A发出配对请求 我们可以看到点击B进行配对后,从A设备首先弹出对话框,要求输入pin码,输入后,发出请求的B设备输入A决定的pin码,双方建立连接。 然后输入hciconfig hci0 noauth 奖励连接时只要连接发起方输入pin,本地输入相同的即可建立连接。 可见,auth就是本地设备对远程连接建立发起一方进行PIN的管理。同样题现在hcoconfig的模式中 3。hciconfig hci0 encrypt/unencrypt是对hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Packet type: DM1 发送数据过程中是否对发送数据进行加密的管理。 4。sudo hciconfig hci0 piscan hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 UP RUNNING PSCAN ISCAN AUTH ENCRYPT RX bytes:4912 acl:0 sco:0 events:209 errors:0 TX bytes:2871 acl:0 sco:0 commands:168 errors:0 为了验证这条命令的作用,我们首先使用hciconfig hci0 no scan 然后使用hcitool -i hci0 inq 00:A0:C6:FF:FF:FF 结果没有反应 然后我们输入hciconfig hci0 piscan sudo hcitool -i hci0 inq 00:A0:C6:FF:FF:FF Inquiring ... 00:A0:C6:FF:FF:FF clock offset: 0x32c0 class: 0x58020c 可以我们使用inquire命令可以得到时钟便宜等参数 5。 sudo hciconfig hci0 iscan 这条命令使本地设备可以进行inquire操作 hcitool -i hci0 inq 00:A0:C6:FF:FF:FF Inquiring ... 00:A0:C6:FF:FF:FF clock offset: 0x32c0 class: 0x58020c 注意:进行inquire扫描的时候被扫描设备要设置为可发现 hciconfig hci0 pscan则是启动page scan 注意:使用这两条命令,只能启用inquire和page中的一种,如果想两种都用的话,就要使用piscan参数 并且之启用其中一种是不能建立连接的,因为我们知道inquire和page是建立连接的两个不可分割的部分,inqure是扫描设备,获取设备的参数,而page就好现网络建立过程中的三次握手一样,是交换pin码的过程。 6。hciconfig hci0 ptype hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 这样就列出了蓝牙支持的不同的数据包类型 Packet type: 包类型 蓝牙系统的基带一共定义了 13 种包类型。所有蓝牙系统协议栈的高层使用这些包类型组成 PDU. 这些包类型包括同时针对 SCO 和 ACL 链路的 ID , NULL , POLL , FHS , DM1 。只为 ACL 链路的数据包 DH1 , AUX1 , DM3 , DH3 , DM5 , DH5 ,只为 SCO 链路建立的 HV1 , HV2 , HV3 , DV 。 DM Data - Medium Rate 中等速率数据,一种中等速率数据的异步传输链路的数据包类型。 DM1 搭载信息数据和 16-bit 的冗余校验码,一共 18 个字节。它们使用 2/3 前向纠错编码( FEC ),该包仅仅用到一个时隙。 DM3 数据包和 DM1 很相似但是可以占用 3 个时隙,并且负载多达 123 个信息字节。 DM5 可以占用 5 个时隙且负载多达 226 个信息字节。 DH Data-High Rate 高速率数据,用于异步链接( ACL link )的高速率数据的包类型。 DH1 包类似于 DM1 包,只有一点不同: payload 中的信息没有进行前向纠错编码( FEC )。这意味着 DH1 包可以在一个时隙中,携带多达 28 字节的信息。 DH3 包也与此类似,只有一点不同:它可以覆盖多达三个时隙,并且包含 185 字节信息。同样, DH5 包可以覆盖到五个时隙,并且包含多达 341 字节的信息。参见蓝牙 packet types. 如果我们输入sudo hciconfig hci0 ptype DM1 结果hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Packet type: DM1 使用这条命令可以设置不同的数据包类型 7。hciconfig hci0 lm命令是得到和改变当前蓝牙设备的状态是主设备还是从设备 sudo hciconfig hci0 lm master $ hciconfig hci0 lm hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Link mode: MASTER 8。lp参数则是当前设备支持的连接策略 ~$ hciconfig hci0 lp hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Link policy: RSWITCH HOLD SNIFF PARK 9。name参数是得到和修改本地设备的名称 ~$ hciconfig hci0 name hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Name: 'hhh' 如果要修改 sudo hciconfig hci0 name yang hciconfig hci0 name hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Name: 'yang' hciconfig hci0 class hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Class: 0x0a0104 Service Classes: Networking, Capturing Device Class: Computer, Desktop workstation 至于class的设定项,我还不是很清楚 10。 hciconfig hci0 voice hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Voice setting: 0x0060 (Default Condition) Input Coding: Linear Input Data Format: 2's complement Input Sample Size: 16 bit # of bits padding at MSB: 0 Air Coding Format: CVSD 也需要后面补充,将在蓝牙核心协议中进行阐述 11。 hciconfig hci0 iac hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 IAC: 0x9e8b33 得到inquire access code.什么是inquire access code 12. sudo hciconfig hci0 inqtpl Can't read inquiry transmit power level on hci0: Connection timed out (110) 13. sudo hciconfig hci0 inqmod hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Inquiry mode: Inquiry with RSSI 14. sudo hciconfig hci0 inqdata Can't read extended inquiry response on hci0: Connection timed out (110) 15. ~$ sudo hciconfig hci0 inqtype hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Inquiry scan type: Standard Inquiry Scan sudo hciconfig hci0 inqparms hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Inquiry interval: 2048 slots (1280.00 ms), window: 18 slots (11.25 ms) 16. sudo hciconfig hci0 pageparms hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Page interval: 2048 slots (1280.00 ms), window: 18 slots (11.25 ms) 17. sudo hciconfig hci0 pageto得到page超时的时间 hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Page timeout: 8192 slots (5120.00 ms) 18。sudo hciconfig hci0 afhmode hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 AFH mode: Disabled 19。udo hciconfig hci0 sspmode Can't read Simple Pairing mode on hci0: Connection timed out (110) 20。aclmtu Set ACL MTU and number of packets scomtu Set SCO MTU and number of packets 设定mtu和蓝牙buffer的大小,需要知道设定的范围 21。putkey Store link key on the device delkey Delete link key from the device putkey是在设备上设定连接的pin码 22。sudo hciconfig hci0 oobdata Can't read local OOB data on hci0: Connection timed out (110) 23。 sudo hciconfig hci0 commands hci0: Type: USB BD Address: AA:BB:CC:56:34:12 ACL MTU: 339:6 SCO MTU: 180:1 Commands: Octet 0 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 1 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 2 = 0xfb (Bit 0 1 3 4 5 6 7) Octet 3 = 0x03 (Bit 0 1) Octet 4 = 0xce (Bit 1 2 3 6 7) Octet 5 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 6 = 0xef (Bit 0 1 2 3 5 6 7) Octet 7 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 8 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 9 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 10 = 0x7c (Bit 2 3 4 5 6) Octet 11 = 0xff (Bit 0 1 2 3 4 5 6 7) Octet 12 = 0xf3 (Bit 0 1 4 5 6 7) Octet 13 = 0x07 (Bit 0 1 2) Octet 14 = 0xe8 (Bit 3 5 6 7) Octet 15 = 0xee (Bit 1 2 3 5 6 7) Octet 16 = 0x3f (Bit 0 1 2 3 4 5) 'Inquiry' 'Inquiry Cancel' 'Periodic Inquiry Mode' 'Exit Periodic Inquiry Mode' 'Create Connection' 'Disconnect' 'Add SCO Connection' 'Cancel Create Connection' 'Accept Connection Request' 'Reject Connection Request' 'Link Key Request Reply' 'Link Key Request Negative Reply' 'PIN Code Request Reply' 'PIN Code Request Negative Reply' 'Change Connection Packet Type' 'Authentication Requested' 'Set Connection Encryption' 'Change Connection Link Key' 'Remote Name Request' 'Cancel Remote Name Request' 'Read Remote Supported Features' 'Read Remote Extended Features' 'Read Remote Version Information' 'Read Clock Offset' 'Read LMP Handle' 'Hold Mode' 'Sniff Mode' 'Exit Sniff Mode' 'QoS Setup' 'Role Discovery' 'Switch Role' 'Read Link Policy Settings' 'Write Link Policy Settings' 'Read Default Link Policy Settings' 'Write Default Link Policy Settings' 'Flow Specification' 'Set Event Mask' 'Reset' 'Set Event Filter' 'Flush' 'Read PIN Type' 'Write PIN Type' 'Read Stored Link Key' 'Write Stored Link Key' 'Delete Stored Link Key' 'Write Local Name' 'Read Local Name' 'Read Connection Accept Timeout' 'Write Connection Accept Timeout' 'Read Page Timeout' 'Write Page Timeout' 'Read Scan Enable' 'Write Scan Enable' 'Read Page Scan Activity' 'Write Page Scan Activity' 'Read Inquiry Scan Activity' 'Write Inquiry Scan Activity' 'Read Authentication Enable' 'Write Authentication Enable' 'Read Encryption Mode' 'Write Encryption Mode' 'Read Class Of Device' 'Write Class Of Device' 'Read Voice Setting' 'Write Voice Setting' 'Read Automatic Flush Timeout' 'Write Automatic Flush Timeout' 'Read Num Broadcast Retransmissions' 'Write Num Broadcast Retransmissions' 'Read Transmit Power Level' 'Read Synchronous Flow Control Enable' 'Write Synchronous Flow Control Enable' 'Set Host Controller To Host Flow Control' 'Host Buffer Size' 'Read Link Supervision Timeout' 'Write Link Supervision Timeout' 'Read Number of Supported IAC' 'Read Current IAC LAP' 'Write Current IAC LAP' 'Read Page Scan Period Mode' 'Write Page Scan Period Mode' 'Read Page Scan Mode' 'Write Page Scan Mode' 'Set AFH Channel Classification' 'Read Inquiry Scan Type' 'Write Inquiry Scan Type' 'Read Inquiry Mode' 'Write Inquiry Mode' 'Read Page Scan Type' 'Write Page Scan Type' 'Read AFH Channel Assessment Mode' 'Read Local Version Information' 'Read Local Supported Features' 'Read Local Extended Features' 'Read Buffer Size' 'Read BD ADDR' 'Read Failed Contact Counter' 'Reset Failed Contact Counter' 'Read RSSI' 'Read AFH Channel Map' 'Read BD Clock' 'Read Loopback Mode' 'Write Loopback Mode' 'Enable Device Under Test Mode' 'Setup Synchronous Connection' 'Accept Synchronous Connection' 'Reject Synchronous Connection' 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yangwenchao1983/archive/2009/09/28/4610294.aspx

更多相关文章

  1. CTS测试介绍
  2. Android输入密码时显示与隐藏
  3. 解决 EditText 屏蔽输入窗口问题
  4. 【Android(安卓)adb】 adb环境变量配置
  5. Linux Android(安卓)studio配置任意目录终端启动和别名启动
  6. Android(安卓)设备管理器 理解和使用
  7. android琐碎问题拾计
  8. Android(安卓)蓝牙通信
  9. android中editText弹出软键盘并且根据editText中是否是内容来控

随机推荐

  1. Android studio导入Github的项目
  2. 键盘设备三星在Android上的改进对Develop
  3. eclipse android sdk can`t fount adb.ex
  4. 关闭 / 隐藏 Android(安卓)软键盘
  5. Android工具箱APP源码分享:“一个工具箱”
  6. Android知识简单测试题
  7. Android中View的滑动
  8. Android 使用ORMLite打造万能泛型Dao简化
  9. 1.Android(了解Android王国)
  10. Service和Activity通讯的3种常用方式示例