Chinaunix首页 | 论坛 | 博客
  • 博客访问: 305524
  • 博文数量: 43
  • 博客积分: 2071
  • 博客等级: 大尉
  • 技术积分: 488
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-25 17:48
文章分类

全部博文(43)

文章存档

2014年(5)

2013年(4)

2011年(9)

2010年(8)

2009年(17)

我的朋友

分类: 系统运维

2011-07-13 18:03:04

1 read local name:
hcitool cmd 0x03 0x0014

2 write local name:
for example, set to name to "kreed", we need use the below command, please note: the length of name should be 248 octets.
hcitool cmd 0x03 0x0013 0x6b 0x72 0x65 0x65 0x64 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

3. enable iscan and disable pscan:
hcitool cmd 0x03 0x001A 0x01

4. enable both iscan and pscan:
hcitool cmd 0x03 0x001A 0x03

5. inquiry and get inquiry result
5.1 firstly use hcidump -V to get dump information.

5.2 send command to inquiry.
/tmp # hcitool cmd 0x01 0x0001 0x33 0x8B 0x9E 0x08 0x00                         
< HCI Command: ogf 0x01, ocf 0x0001, plen 5
  33 8B 9E 08 00 
> HCI Event: 0x0f plen 4
  00 01 01 04 

/tmp # hcitool cmd 0x01 0x0019 0xB0 0xBD 0xD4 0xE5 0x4C 0x90 0x00 0x00 0x00 0x00
< HCI Command: ogf 0x01, ocf 0x0019, plen 10
  B0 BD D4 E5 4C 90 00 00 00 00 
> HCI Event: 0x0f plen 4
  00 01 19 04 

0xB0 0xBD 0xD4 0xE5 0x4C 0x90 means BT address 90:4C:E5:D4:BD:B0, which is obtained from hcidump log.

5.3 as we said, we have already launch hcidump while we execute hcitool command. the below is dump log.
hcidump -V
I sniffer - Bluetooth packet analyzer ver 1.42
device: hci0 snap_len: 1028 filter: 0xffffffff
< HCI Command: Inquiry (0x01|0x0001) plen 5
    lap 0x9e8b33 len 8 num 0
> HCI Event: Command Status (0x0f) plen 4
    Inquiry (0x01|0x0001) status 0x00 ncmd 1
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 00:24:23:18:58:B3 mode 1 clkoffset 0x3f02 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 50:63:13:96:33:FD mode 1 clkoffset 0x290f class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4763 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 50:63:13:90:54:AE mode 1 clkoffset 0x58fe class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 50:63:13:90:54:AE mode 1 clkoffset 0x58ff class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 50:63:13:90:54:AE mode 1 clkoffset 0x58ff class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4762 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4763 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4762 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4763 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 00:24:23:18:58:B3 mode 1 clkoffset 0x3f02 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4762 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 90:4C:E5:D4:BD:B0 mode 1 clkoffset 0x4763 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 70:F1:A1:00:27:B8 mode 1 clkoffset 0x5645 class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr 50:63:13:90:54:AE mode 1 clkoffset 0x58ff class 0x000000
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Result (0x02) plen 15
    bdaddr F4:FC:32:47:B1:39 mode 1 clkoffset 0x16a1 class 0x58020c
> HCI Event: Inquiry Complete (0x01) plen 1
    status 0x00

< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr 90:4C:E5:D4:BD:B0 mode 0 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 90:4C:E5:D4:BD:B0 name 'Dell Wireless 370 Bluetooth Mini-card'

5.4 from the above dump log, we can get detailed information about remote device:
status 0x00 bdaddr 90:4C:E5:D4:BD:B0 name 'Dell Wireless 370 Bluetooth Mini-card'
阅读(10880) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

joqian2013-03-29 16:48:04

如果写成应用程序,该如何写呢? 并且如何接收返回的信息呢? 你有做过没你不呢?谢谢哦。正在困惑中