|
* What is ..."Bluetooth" ?
Bluetooth 技術最早起源於 1994 年, 當初是由瑞典的手機業者 Ericsson 研究如
何以無線通訊的方式取代現有手機與各種周邊配件的有線連結; 一直到了 1998 年
才由 Communication, Computing, Electronics, ...各方面的大公司(Ericsson,
IBM, Intel, Nokia, Toshiba)成立研究小組(Bluetooth SIG, Special Intrest Group), 並定名為"Bluetooth" ...這個名
字取自西元十世紀的丹麥國王 Harald Blaatand 二世(940-981), 紀念他為了丹麥
- 挪威的和平與溝通作出偉大貢獻, 而丹麥文的 Blaatand 即英文中 Bluetooth
之意, 故依此為名。
* About "BlueZ" ...
從 Bluetooth 的 specification 中我們可以知道: 整個 Bluetooth Archieteture
除了硬體的 RF Module, Base Band, Link Manager 之外, 還需要軟體部分的 L2CAP,
RFcomm Module, SDP, TCS。而 BlueZ 就是負責軟體的這部分(除了與 Telecom 相
關的 TCP 外), 目前 BlueZ 的網頁在 SourceForge, support 的 Platform 以 Linux
2.4.x 為主, 最新版本是 2.0-pre2 (01.27.2002)。整個 BlueZ 提供的檔案功能
分述如下:
filename |
release date |
function |
bluez-2.0-pre1.tar.gz |
01.27.2002 |
Daemon: hcid
Driver: l2cap, hci_uart, hci_usb, ...
Tools: l2ping, l2test, hcitool, ... |
hcidump-1.0.tar.gz |
11.14.2001 |
|
hciemu-0.2.tar.gz |
08.21.2001 |
|
rfcommd-1.1.tar.gz |
07.20.2001 |
|
sdpd-0.1.tar.gz |
08.21.2001 |
|
* Our Platform
RedHat 7.0 with CLE 1.0, kernel 更新至 2.4.16
FIC (大眾電腦) Bluetooth Evaluation Kit
(BT-EVKV1) via
USB connection
[註] BT-EVKV1 亦可使用 RS232 作為與電腦間的連線, 但使用時需要 6 Volt 的 DC 外部電源
* Refrence Document
Linux USB Guide: linux-usb.org
BlueZ HOWTO: bluez.sourceforge
[Linux Document Plane] PPP HowTo
* USB support ?
由於接下來我們要使用到 PC 上的 USB prot 作連接, 所以必須先確認你的 USB
能在 Linux 下正確地被驅動(如果使用 Serial port 者則需要驅動 UARTS)。
Linux 下把 USB controller 分成兩類, 一為 UHCI(Intel,VIA) , 另一為 OHCI
(Compaq, iMacs, OPTi, SiS, ALi); 基本上只要記得把 "Support for USB",
"Preliminary USB device filesystem", 與對應的 controller support make 進
kernel 或 module, 這樣子就可以了。
除此, 如果你有其他 USB device (like: mouse or keyboard) 來做個測試當然是
更好不過的了, 因為依照個人經驗: 發現驅動後總是會不穩定地出現錯誤, 常跟原
本在介面的驅動上正確否有關。如果你跟我一樣有 USB mouse 的話, 請記得選取
"Input core support"與"Mouse support", 並且不要選擇"USB HIDBP Mouse
(basic) support"。
Step 1: Install bluez-2.0-pre1
|
> tar zxvf bluez-2.0-pre1.tar.gz
> cd ./bluez-2.0-pre1
> ./configure --with-kernel=/usr/src/linux-2.4.16
/* 如果 source kernel 在 /usr/src/linux 則不必加 --with-kernel 的參數 */
> make update
/* if kernel is 2.4.6-pre2 or later */
> make
> make install
|
全部 make 完成之後, 程式會將會生成的 modules copy 到 /lib/modules 裡相應
的目錄下。
|
> ls /lib/modulrs/2.4.16/kernel/drivers/bluetooth
bluez.o hci_uart.o hci_usb.o hci_vhci.o l2cap.o rfcomm.o sco.o
|
各個 modules 的作用分述如下:
module name |
function |
bluez.o |
這是 BlueZ 的核心檔案, 在舊版 HowTo 中的名稱是 hci.o
安裝後系統會自動載入 |
hci_uart.o |
for UART(RS232) connection only |
hci_usb.o |
for USB connection only |
hci_vhci.o |
如果你沒有實際的 Bluetooth device, 這裡提供 Virtual HCI device 的功能 |
l2cap.o |
Link Manager 上面的那塊, 一定要載入 |
rfcomm.o |
unknown |
sco.o |
unknown |
Step 2: Load Modules & Bring-up Device
和一般的 modules 一樣, 你可以選擇使用 auto-loading 或是 Manual-loading
的方式, 這邊以 USB connection 加上 Manual-Loading 為例...
|
> depmod -a
> modprobe bluez
> modprobe l2cap
> hcid /* auto-initialzation & authentication */
> modprobe hci_usb
> hciconfig hci0 /* ensure device status */
hci0: Type: USB
BD Address: 00:D0:B7:03:4A:7C ACL MTU:800:10 SCO: MTU 255:255
UP RUNNING PSCAN ISCAN
RX bytes:63 acl:0 sco:0 events:7 errors:0
TX bytes:27 acl:0 sco:0 commands:7 errors:0
> lsmod
Module |
Size |
Used by |
hci_usb |
5440 |
0 (unused) |
l2cap |
13072 |
0 (unused) |
bluez |
23936 |
0 [hci_usb l2cap] |
uhci |
24624 |
0 (unused) |
usbcore |
53536 |
1 [hci_usb uchi] |
|
如果能夠順利的看到 Bluetooth device 卡號就代表已經 bring-up 成功囉~ 接下
來可以試試 ./bluez-2.0-pre2/tools/ 裡頭那些工具程式或者建立 rfcommd 層。
Step 3: Test Bluetooth device
[bluepin]: unknown, 每次執行都會出現 error messages。
> ./bluepin
Traceback (innermost last):
File "/bin/bluepin", line 22, in ?
from gtk import *
File "/usr/lib/python1.5/site-package/gtk.py", line 29, in ?
_gtk.gtk_init()
RuntimeError: cannot open desplay
PRE> |
[hciattach]: for RS232(UART) connection only, 用來取代 hcid 作 load modules
與 bring-up device 的動作。
> ./hciattach
hciattach - HCI UART driver initialization utility
Usage:
hciattach [speed] [flow]
PRE> |
[l2test]: 必須把兩塊 Bluetooth device 連接到不同的電腦上才能 work
先用 BlueZ HowTo 中 Tools Examples (Trace 1) 的方式:
(Server)
> hciconfig hci0
hci0: Type: USB
BD Address: 00:D0:B7:03:4A:69 ACL MTU:800:10 SCO: MTU 255:255
UP RUNNING PSCAN ISCAN
RX bytes:63 acl:0 sco:0 events:7 errors:0
TX bytes:27 acl:0 sco:0 commands:7 errors:0
> ./l2test -I 2000 -r
l2test[893]: Waiting for connection on psm 10 ...
(Client)
> hciconfig hci0
hci0: Type: USB
BD Address: 00:D0:B7:03:4A:7C ACL MTU:800:10 SCO: MTU 255:255
UP RUNNING PSCAN ISCAN
RX bytes:63 acl:0 sco:0 events:7 errors:0
TX bytes:27 acl:0 sco:0 commands:7 errors:0
> ./l2test -O 2000 -s 00:D0:B7:03:4A:69
l2test[641]: Can't connect. Resource temporarily unavailable(11)
l2test[641]: Can't connect to the server. Resource temporarily
unavailable(11)
PRE> |
發現 ...Client 等了好久仍然無法取得連接, 改以 HowTo 裡原先介紹 l2test 時
的用法, Client 端不加 "-O 2000" 的參數。
(Client)
> ./l2test -s 00:D0:B7:03:4A:69
l2test[642]: Connected [imtu 672, omtu 2000, flush_to 65535]
l2test[642]: Sending ...
(Server)
l2test[894]: Connect from 00:D0:B7:03:4A:7C [imtu 2000, omtu 672,
flush_to 65535]
l2test[894]: Receiving ...
l2test[894]: 672 bytes in 0.00m speed 12.59 kb
l2test[894]: 672 bytes in 0.00m speed 18.92 kb
l2test[894]: 672 bytes in 0.00m speed 20.67 kb
l2test[894]: 672 bytes in 0.00m speed 19.43 kb
l2test[894]: 672 bytes in 0.00m speed 20.68 kb
... [Ctrl-C]
(Client)
l2test[642]: Send failed. Connection reset by peer(104)
PRE> |
it works !! 最後我們在 Server 端按下 [Ctrl-C] 中止, Client 也立即偵測到
connection reset。
[l2ping]: 這跟平常使用的 ping 很像, 純粹是測試連線的反應時間, 參數有...
-c 指定送出的封包個數。
-f 連續地送出封包; 不加這參數時 l2ping 會以一秒鐘一個的速度送出封包。
-s 指定送出的封包大小(data size)。
-S 後邊加上 local Bluetooth 的卡號; 或許在一台電腦上有多個 Bluetooth
device 時才會有作用。
> ./l2ping -c 4 00:D0:B7:03:4A:69
Ping: 00:D0:B7:03:4A:69 from 00:D0:B7:03:4A:7C (data size 20) ...
20 bytes from 00:D0:B7:03:4A:69 id 200 time 18.72ms
20 bytes from 00:D0:B7:03:4A:69 id 201 time 22.18ms
20 bytes from 00:D0:B7:03:4A:69 id 202 time 21.99ms
20 bytes from 00:D0:B7:03:4A:69 id 203 time 21.80ms
4 sent, 4 received, 0% loss
PRE> |
[scotest]: unknown, 即使在執行前載入 sco.o, 還是會在 connect 之後
即 hang 住。
(Server)
> modprobe sco
> ./scotest -r
scotest[892]: Waiting for connection ...
(Client)
> modprobe sco
> ./scotest -s 00:D0:B7:03:4A:69
scotest[676]: Connected
scotest[676]: Sending
(Server)
scotest[893]: Connect from 00:D0:B7:03:4A:7C
scotest[893]: Receiving ...
PRE> |
Step 4: Other Tools from BlueZ
[略], 這邊 BlueZ 總共提供了三個工具程式 --- hcidump, hciemud, hcitool,
可是經過 HowTo 上的說明, 還是無法將任何一個作正確的執行。
Step 5: Build RFCOMM & PPP(Point-to-Point) Layer
keep working... 這層目前遇到的問題主要在於簽入端(Client)會在認證後自動地
發生"modem hangup"的現象
* Question & Answer *
[keyword] |
statement |
date |
platform |
confirm |
[HCID] |
Only 2 things don't work if HCId is not running. (1) Device auto-initialization,
(2) Authentication. #1 ~= "hciconfig hciX up" so you can do it
manually. |
01/28/2002 |
BlueZ 2.0-pre1 |
Maksim Krasnyanskiy |
[Ericsson] [USB] |
使用 USB 作為 Ericsson Module 的連接時, l2ping 與 l2test 將產生測試失
敗(especially on reciever side); 如果修改 hci_usb.h 為 HCI_MAX_RX_URB_QLEN = 1,
l2ping works. |
01/23/2002 |
BlueZ 2.0-pre1, kernel 2.4.17 |
Maksim Krasnyanskiy |
[BLIP] |
Client can't terminate connection properly when using Ericsson BLIP
on server side. |
01/14/2002 |
--- |
Harald Mayer |
[Ericsson] |
When using Ericsson training kit, you can plug it with self-powered
USB hub intead with power supply. |
01/22/2002 |
--- |
Nils Faerber |
[l2test] |
When l2test show error message: Can't Connect. Resource temporitily
unaviable (11) Can't Connect to the server. Resource temporitily
unaviable (11) It is usually reported when device tried to connect
but something failed on baseband level. Try to set smallest packet type
(hciconfig hciX ptype DM1) and reconnect. btw You should upgrade
firmware on your Ericssons. |
01/21/2002 |
--- |
Maksim Krasnyanskiy |
[Ericsson] |
Old Ericsson firmware(s) have a lot of USB problems. One of them is
packet loss. You should try to upgrade FW. |
01/21/2002 |
--- |
Maksim Krasnyanskiy |
* Relative Item
* Ericsson BLIP
* http://www.hpl.hp.com/personal/Jean_Tourrilhes/bt/Brainboxes.html
* Axis OpenBT
|
Bluetooth SIG Logo
Bluetooth Archieteture
Bluetooth Evaluation Kit
Ericsson ROK 101 008 Bluetooth Modules
|