♩About myself♪

我的相片
永遠的藍星
怠惰是一種病,偷懶是種藉口

Panda dog?

2008年8月14日 星期四

Linux bluetooth基本操作

支持 usb_hci rfcomm 協定軟體 bluez 載入hci_usb、 rfcomm模組# modprobe hci_usb # modprobe rfcomm 插入usb receriver # hciconfig hci0 up 指令啟動裝置
查詢usb receriver狀態 # hciconfig -a
hci0: Type: USB BD Address: 00:10:60:A3:68:9F ACL MTU: 192:8 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:1860 acl:10 sco:0 events:88 errors:0 TX bytes:1432 acl:10 sco:0 commands:52 errors:0 Features: 0xff 0xff 0x0f 0x00 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'Debian' Class: 0x000100 Service Classes: Unspecified Device Class: Computer, Uncategorized HCI Ver: 1.1 (0x1) HCI Rev: 0x20d LMP Ver: 1.1 (0x1) LMP Subver: 0x20d Manufacturer: Cambridge Silicon Radio (10)
掃瞄周圍藍牙設備:
# hcitool scan Scanning ... 00:0B:0D:85:13:53 HOLUX GPSlim236 00:11:94:02:1A:84 MPx220 00:19:2D:E0:33:77 628...............i love it 00:18:0F:CE:2B:4B ...........................
Ping一下看看: (指令為l2ping,l是小寫的L而不是數字1) )
# l2ping 00:0E:07:1C:AE:1D
Ping: 00:0B:0D:85:13:53 from 00:10:60:E3:7D:E0 (data size 44) ... 0 bytes from 00:0B:0D:85:13:53 id 0 time 10.83ms 0 bytes from 00:0B:0D:85:13:53 id 1 time 6.42ms 0 bytes from 00:0B:0D:85:13:53 id 2 time 6.36ms 0 bytes from 00:0B:0D:85:13:53 id 3 time 6.28ms 0 bytes from 00:0B:0D:85:13:53 id 4 time 6.07ms 0 bytes from 00:0B:0D:85:13:53 id 5 time 5.22ms 0 bytes from 00:0B:0D:85:13:53 id 6 time 6.18ms 0 bytes from 00:0B:0D:85:13:53 id 7 time 5.09ms 0 bytes from 00:0B:0D:85:13:53 id 8 time 11.07ms 0 bytes from 00:0B:0D:85:13:53 id 9 time 7.03ms 10 sent, 10 received, 0% loss #O#有反應
本地主機配置文件(主機名等參數): /etc/bluetooth/hcid.conf
....
# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
#lm accept; #改成註解 lm accept,master #這邊設定為伺服模式 ....
PIN配對碼所在文件: /etc/bluetooth/pin 我設在/bin/bluepin
內容
#!/bin/sh echo
"PIN:0000"
加載配置文件: #hcid -f /etc/bluetooth/hcid.conf
透過rfcomm連線 #rfcomm connect /dev/rfcomm0 00:0E:07:1C:AE:1D ﹍(參數設定通道) Connected /dev/rfcomm0 to 00:0B:0D:85:13:53 on channel 1 Press CTRL-C for hangup 用串口查看裝置傳輸內容 #minicom -s set
┌───────────────────────┐
│ A - Serial Device : /dev/rfcomm0
│ B - Lockfile Location : /var/lock
│ C - Callin Program :
│ D - Callout Program :
│ E - Bps/Par/Bits : 115200 8N1
│ F - Hardware Flow Control : Yes
│ G - Software Flow Control : No │
│ Change which setting?
└───────────────────────┘
儲存設定後esc就可以看到以下數據:$GPGGA,062721.764,2459.7236,N,12127.1011,E,0,00,,46.4,M,15.2,M,,0000*4A $GPRMC,062721.764,V,2459.7236,N,12127.1011,E,,,150808,,,N*7B $GPVTG,,T,,M,,N,,K,N*2C $GPGGA,062722.761,2459.7236,N,12127.1011,E,0,00,,46.4,M,15.2,M,,0000*4C $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,3,1,11,16,47,019,,06,84,102,,03,74,212,,23,47,291,*77 $GPGSV,3,2,11,19,41,204,19,31,41,100,,13,21,317,18,25,14,317,*77 $GPGSV,3,3,11,21,11,068,,32,06,216,,20,04,236,*47 $GPRMC,062722.761,V,2459.7236,N,12127.1011,E,,,150808,,,N*7D $GPVTG,,T,,M,,N,,K,N*2C 由GPS接收器收到的訊號

沒有留言: