歡迎您光臨本站 註冊首頁

LINUX 藍牙耳機的配置方法

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  由於經常使用SKYPE聊天打電話,一直覺得被拴在電腦前面不是很自由,終於在一個周末,一激動買了一個藍牙耳機.經過幾天的努力在Linux/Debian上用了起來,現在就把這個配置過程和大家分享.

  第一 了解藍牙

  藍牙是愛立信的提出的一個近距離的無線通訊協議,由於沒有INTEL的支持,它的發展一直都不是很快,在藍牙不多的應用中,用得最多就是無線的HEADSET.其他應用還有MOUSE,CAMERA. 藍牙耳機主要有兩種PROFILE,一般用的都是Headset profile它是單聲道的音頻,質量只能用於做打電話.新的Advance Audio Distribution Profile 支持立體聲,用來聽音樂沒有問題(發燒友除外)

  bluetooth 的LINUX的STACK主要有兩個 Affix 和 BlueZ,我使用的是后一種.

  參考1 linux.html">http://www.tuxmobil.org/bluetooth_linux.html

  第二 環境

  thinkpad X31

  debian sarge,

  linux kernel 2.6.11

  USB Bluetooth 1.1 adaptor (不記得是哪個公司的東東了)

  plantronic M3000 BT Headset

  第三 kernel setting

  我喜歡用比較新的KERNEL,低版本的經常需要打很多PATCH,很不方便.不過如果你很經常的自做debian的包,還是用sarge帶的kernel.

  in Kernel 2.6

  Device Driver ->Networking Support ->(M) Bluetooth Sub system Support

  我用的是USB的adaptor我沒有選PC卡,如果你是用的PC卡,應該把它們選上.

  第四 下載DEBIAN的BLUETOOTH的包

  你可以用apt-cache search bluetooth看一下SARGE下的和藍牙有關的包.

  我安裝了

  ii bluez-cups 2.15-1 Bluetooth printer driver for CUPS

  ii bluez-hcidump 1.17-1 Analyses Bluetooth HCI packets

  ii bluez-pcmcia-s 2.15-1 PCMCIA support files for BlueZ 2.0 Bluetooth

  ii bluez-pin 0.25-1 Bluetooth PIN helper with D-BUS support

  ii bluez-utils 2.15-1 Bluetooth tools and daemons

  ii libbluetooth1 2.15-2 Library to use the BlueZ Linux Bluetooth sta

  ii libbluetooth1- 2.15-2 Development files for using the BlueZ Linux

  第五 下載KDE或者GNOME下的藍牙的圖形化管理工具

  GNOME

  http://usefulinc.com/software/gnome-bluetooth/

  APT的地址: deb http://debian.usefulinc.com/gnome ./

  如果你有藍牙的電話,你還可以在上面的網站上找到phone manager

  http://usefulinc.com/software/phonemgr/

  我沒有支持藍牙的手機,沒有測試它

  KDE

  http://kde-bluetooth.sourceforge.net/

  DEB 包 http://fred.hexbox.de/debian/

  deb http://fred.hexbox.de/debian ./

  第六 藍牙的配置文件

  藍牙的配置文件位於/etc/bluetooth目錄下面.

  hcid.conf

  # HCId options

  options {

# Automatically initialize new devices

autoinit yes;

# Security Manager mode

# none - Security manager disabled

# auto - Use local PIN for incoming connections

# user - Always ask user for a PIN

#

security user;

  這裡最好改成user 一般的耳機在連接時都需要輸入PIN,雖然第二次,選auto有時,經常會出現連不上死在那裡的情況.

# Pairing mode

# none - Pairing disabled

# multi - Allow pairing with already paired devices

# once - Pair once and deny successive attempts

pairing multi;

# PIN helper

#pin_helper /usr/bin/bluez-pin;

pin_helper /usr/lib/kdebluetooth/kbluepin;

  我用的是kde的藍牙的framework,

  pin helper,的作用是在藍牙設備需要輸入密碼時,彈出對話框讓你讓打密碼.

# D-Bus PIN helper

#dbus_pin_helper;

}

# Default settings for HCI devices

device {

# Local device name

# %d - device id

# %h - host name

name "%h-%d";

# Local device class

class 0xff0100

  oxff0100的意思是接受任何種類的藍牙設備的連接,

  0x200404 是指只接受audio/video device類的設備連接.

  這個主要用於你有多台藍牙設備時,想控制他們的互相連接時使用.

  例如你有兩台電腦,一個手機都帶有藍牙,而你只想讓電話連到一台腦上,就可以使用這種方法來設置.

# Default packet type

#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan

iscan enable; pscan enable;

# 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;

# Default link policy

# none - no specific policy

# rswitch - allow role switch

# hold - allow hold mode

# sniff - allow sniff mode

# park - allow park mode

lp rswitch,hold,sniff,park;

# Authentication and Encryption (Security Mode 3)

auth enable;

#encrypt enable;

  感覺還是打開驗證的比較好,選AUTO,BT會記住以前的PAIR, 在連接藍牙設備時,如果以前PAIR過了,就會直接用以前記住的PIN去連接,這個看上去不錯,但我用下了經常會有連不上的情況.

  }

  第六 安裝藍牙耳機的音頻程序

  前提:你的linux應該使用的是ALSA的音頻系統.

  http://cgi.sfu.ca/~jdbates/debian/pool/bluetooth-alsa/

  deb包 deb http://cgi.sfu.ca/~jdbates/debian/ . .

  bluetooth-alsa_200503090-1_i386.deb  2005年5月19日

  這個包會裝安裝btsco的應用程序.

  現在我們還需要一個驅動程序.snd-bt-sco

  1.到bluetooth-alsa項目的主頁去下載源程序 或從CVS中下最新的代碼.

  http://bluetooth-alsa.sourceforge.net/

  從CVS中可以得到最新的程序

  cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bluetooth-alsa login

  cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bluetooth-alsa co btsco

  編譯前需要的包

  automake-1.7

  libbluetooth-dev (aka libbluetooth-devel or bluetooth-devel)

  libasound2-dev (aka alsa-devel)

  2.Compile:

./bootstrap

./configure

make

make install

make maintainer-clean

  3. snd-bt-bco需要一個snd_hwdep_new的內核模塊. 你可以通過在編輯內核時選上 emu10k1強行編譯上面的內核模塊.

  device drivers ——> sound ——>Advance Linux sound Architecture——>PCI devices

  ——>(M)Em10k1

  make

  make modules_install

  4.編譯snd-bt-sco

  到btsco/kernel目錄下面

  cd kernel

  make

  make install

  depmod -e

  make clean

  默認的狀態下會安裝在/lib/modules/2.6.X/extra/目錄下面.

  第七 使用藍牙耳機

  1.modprobe snd_bt_sco

  2.hciconfig hci0 voice 0x0060

  3.btsco bdaddress

  這裡需要填的是藍牙的MAC地址

  這可以通過讓你的藍牙耳機處在查詢狀態.然後用hcitool scans就可以找到你的耳機,同時看到它的MAC地址.

  #hcitool scan

  Scanning ……

  第七 使用藍牙耳機

  1. 連接

  hci scan

00:03:89:4C:3A:2E M3000 by Plantronics

  btsco 00:03:89:4C:3A:2E

  連接建立后,藍牙耳機會被的音頻設備會被映射到/dev/dsp1

  2 使用aplay 和arecord 測試藍耳機

  你需要安裝alsaplayer.

  aplay -D plughw:Headset sound.wav 可以向藍牙耳機播放音樂,

  一般需要按一下藍牙耳機的接聽鍵.

  錄音 一般用

  arecord -d 10 -f cd -t wav -D plughw:Headset record.wav

  alsaplayer的具體用法 man 一下吧.

  arecord -d 10 -f cd -t wav -D plughw:Headset record.wav

  3 在SKYPE下使用藍牙耳機

  只需把SKYPE的hand/handset變成/dev/dsp1就可以使用藍牙的耳機了.

  4 XMMS

  LINUX下一個像 winamp的音樂播放器. 你也可以找到他的配置頁,讓他通過/dev/dsp1來播放音樂.

  5 立體聲

  最新一些耳機支持Advance Audio Distribution Profile

  播放的質量和一般的MP3差不多,由於我的耳機不支持這個PROFILE,沒有測試.

  6 音質

  前前後後花了大約三個晚上6個小時,但是的音質還是讓我覺得有點失望.M3000錄音時有點噪音,根本無法和有線的HEADSET相比,不過上網查了一下,M3000好像是問題很多,哎,當初就它的包裝上寫著有降噪的話筒,看來這個周末要處理掉它.


[火星人 ] LINUX 藍牙耳機的配置方法已經有2263次圍觀

http://coctec.com/docs/linux/show-post-56338.html