ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

顯示具有 bluetooth 標籤的文章。 顯示所有文章
顯示具有 bluetooth 標籤的文章。 顯示所有文章

2012年4月9日 星期一

bluez a2dp sink test

首先是這一篇:http://blog.cyphermox.net/2012/03/call-for-testing-bluez-a2dp-and-hsphfp.html

這樣看起來 bluez 好像可以 support A2DP Sink。
所以稍微查一下,
最後是照著這一篇:http://linuxtoy.org/archives/ubuntu-bluetooth-guide.html

用 blueman pair 後才成功。



需要 paluseaudio。

先修改 /etc/bluetooth/audio.conf,在 [General] 後面加上 Enable=SourceL
重新啟動 bluetooth: service bluetooth restart 之後就可以用 blueman (Debian 需要aptitude額外安裝),Bluetooth Manager的 device 作 search,
Blueman 可以選擇 connect to 的 function ,選 "Audio Source"。
一樣,作 pair, trust,connect 後,在 手機上可以看到 已經和 NB 作 媒體音訊 的連接了。

之後手機就可以播放。

手機連接 A2DP 後,在音量控制部份,會多出一個 entry: Device : Capture : 手機名稱(PulseAudio Mixer)


ref:
  1. 圖文並茂版:http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/
  2. dbus command: http://blog.csdn.net/mayouyang/article/details/5940805



不使用 blueman ,手動的部份,參考 ref 2 的後半,還有 http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/

一般的問題都是用 pactl list 找不到 手機 的 source card。
這個 ref 可以看到是用 bluetooth device address 為名。

依照說明,開啟 d-feet,在 device address 的 AudioSource method connect() 按下後,
執行 pactl list | grep Name: 可以看到兩個 entry: Name: bluez_source.5C_B5_24_XX_XX_XX Name: bluez_card.5C_B5_24_XX_XX_XX 這個就是手機連線後,新增加的 sound card 裝置。

follow 說明 load module-loopback 給定對應的 source, sink name ,就可以正確播出聲音了。

.. 我的 pactl list | grep Name: 有關 audio 的是: Name: alsa_output.pci-0000_02_00.1.hdmi-stereo Name: alsa_output.pci-0000_00_1b.0.analog-stereo Name: alsa_output.pci-0000_02_00.1.hdmi-stereo.monitor Name: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor Name: alsa_input.pci-0000_00_1b.0.analog-stereo Name: bluez_source.5C_B5_24_XX_XX_XX Name: alsa_card.pci-0000_02_00.1 Name: alsa_card.pci-0000_00_1b.0 Name: bluez_card.5C_B5_24_XX_XX_XX 所以 load loopback module 的 command 是: pactl load-module module-loopback source=bluez_source.5C_B5_24_XX_XX_XX sink=alsa_output.pci-0000_00_1b.0.analog-stereo
這個command 回 return 一個數字,是 modue 的 index,在 unload-module 時要用。
例如,return 20 的話,unload loopback module 時,要用: pactl unload-module 20


這個blog有詳細的 bluetooth, bluez 解說:
http://blog.sina.com.cn/s/articlelist_1613727600_2_1.html

2012年4月6日 星期五

bluez test tool - l2test, l2ping

bluez 有一些 bluetooth 測試的 tool:
像 ping 一樣動作的 l2ping: 先用 hcitool scan 掃一下 附近 device 的 Address 用 l2ping XX:XX:XX:XX:XX:XX 就像網路的 ping 一樣,會回報回應時間。

也有類似 iperf 一樣的 持續 send, rec 的 client -- server mode testing program:
l2test
Usage: l2test [options] [bdaddr] Modes: -r listen and receive -w listen and send -d listen and dump incoming data -x listen, then send, then dump incoming data -t listen, then send and receive at the same time -q connect, then send and receive at the same time -s connect and send -u connect and receive -n connect and be silent -y connect, then send, then dump incoming data -c connect, disconnect, connect, ... -m multiple connects -p trigger dedicated bonding -z information request Options: [-b bytes] [-i device] [-P psm] [-I imtu] [-O omtu] [-L seconds] enable SO_LINGER [-W seconds] enable deferred setup [-B filename] use data packets from file [-N num] send num frames (default = infinite) [-C num] send num frames before delay (default = 1) [-D milliseconds] delay after sending num frames (default = 0) [-X mode] select retransmission/flow-control mode [-F fcs] use CRC16 check (default = 1) [-Q num] Max Transmit value (default = 3) [-Z size] Transmission Window size (default = 63) [-R] reliable mode [-G] use connectionless channel (datagram) [-U] use sock stream [-A] request authentication [-E] request encryption [-S] secure connection [-M] become master [-T] enable timestamps 實際使用:
Server 的 command: l2test -I 2000 -r
Client 的 command: l2test -O 2000 -s XX:XX:XX:XX:XX:XX

ref:
  1. http://www.jeremythompson.uklinux.net/RH8-0/bluezhowto.pdf

2012年3月29日 星期四

dmesg : plugin broadcom bt dongle

插入broadcom bt dongle 後: [35846.698859] usb 2-1.1.4.3: USB disconnect, address 100 [36348.976683] usb 2-1.2: USB disconnect, address 64 [37771.085747] usb 2-1.1.4.2: new full speed USB device using ehci_hcd and address 101 [37771.199661] usb 2-1.1.4.2: New USB device found, idVendor=0a5c, idProduct=2101 [37771.199665] usb 2-1.1.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [37771.199669] usb 2-1.1.4.2: Product: BT EDR Dongle [37771.199672] usb 2-1.1.4.2: Manufacturer: Broadcom Corp [37771.199809] usb 2-1.1.4.2: configuration #1 chosen from 1 choice 插入csr bt dongle [ 3785.993223] usb 2-1.1.4.3: USB disconnect, address 32 [ 3991.162896] usb 2-1.1.4.2: new full speed USB device using ehci_hcd and address 33 [ 3991.776824] usb 2-1.1.4.2: New USB device found, idVendor=0a12, idProduct=0001 [ 3991.776829] usb 2-1.1.4.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 3991.776969] usb 2-1.1.4.2: configuration #1 chosen from 1 choice [ 3991.830149] Bluetooth: Generic Bluetooth USB driver ver 0.6 [ 3991.831140] usbcore: registered new interface driver btusb

2012年1月30日 星期一

dell N4010 : enable bluetooth

Dell N4010 的 bluetooth 是 Bus 001 Device 008: ID 413c:8160 Dell Computer Corp. Wireless 365 Bluetooth 但是不知道為什麼,在 ubuntu 下 lsusb 沒有出現,只有出現 他的 usb hub : Bus 001 Device 003: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) 猜是沒有 enable,但是 bluetooth enable 。
而且 debian 的 dell hotkey 沒有 support wireless (wifi, bt) 的 switch。

所以,只好..

開到 windows 7 下, enable bluetooth,重新開到 debian ...

bluetooth 出現了...

2010年7月29日 星期四

bluetooth, bluez.. linux

Linux 上的 bluetooth stack 有 affix 和 BlueZ
BlueZ 的說明有 (http://people.csail.mit.edu/albert/bluez-intro/index.html):An Introduction to Bluetooth Programming
要把 Linux 當作是 Headset。和 手機連線。有一篇 bluetooth-alsa (http://bluetooth-alsa.sourceforge.net/)說要去看 Gammu (http://wammu.eu/) 原文章還說明一下 Audio 的部份: audio 傳輸分成 同步和非同步 兩種 (其實說是 即時 與 非即時 比較適當)
  • 同步 (SCO ) : 像手機和 headset 之間,一旦傳送就要馬上送到,以免有延遲。就是同步。
  • 非同步 (A2DP) : 像播放音樂,開始播到真正放出可以有一段 delay.(?)
SCO 是由 HCI 提供。
A2DP 是上層的 profile。
--- 這一段好像寫錯,A2DP 也是用 SCO 才對。
關於把Linux當作 headset 和 phone 連接,可能可以參考 TomTom 的作法。 (http://www.tomtom.com/page.php?Page=gpl#tomtom)

每個 bluetooth device 都有一個 unique 的 48 bit address. 每個 bluetooth device 可以為自己取一個名字 (my phone, nb...),名字可能會跟其他人一樣。 把L2CAP 比作 UDP,把 RFCOMM 比作 TCP。 大概是因為 layer 也一樣吧。 RFCOMM 的底層是 L2CAP。但是實際上 L2CAP 本身就可以做到 connection 和 connection-less 兩種方式。 跟 TCP/IP 一樣,決定 protocol 後,還要只定 port number。但是 Bluetooth 的名字不叫 port。叫 multiplexer。數字也有限制。 和 TCP/IP 不一樣,port 不是寫死的,是在通訊時決定。利用 SDP (Service Discovering Protocol) 決定。 SDP 也是建在 L2CAP 之上。 用 PyBluez 寫 bluetooth code 很方便,像:import bluetooth nearby_device = bluetooth_discover_devices()就可以把所有scan 到的 bluetooth device address 放到 nearby_device 李

標籤

網誌存檔