Linux蓝牙耳机软件,Linux下蓝牙耳机的配置与测试

一、在kernel中启动蓝牙支持

在kernel中使用.config作kernel setting

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

二、安装软件包

yum -y install bluez bluez-libs bluez-utils

在rpm.pbone.net下载btsco软件包,并安装:

sudo rpm -ivh btsco-0.5-39.i486.rpm

三、安装

yum -y install gnome-bluetooth

四、修改蓝牙配置文件

进入/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码,一般默认为0000或者1234

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

#D-Bus PIN helper

#dbus_pin_helper;

}

# Defalut settings for HCI devices

device {

# Local device name

# %d – device id

# %h – host name

name “%h-%d”;

# Local device class

class 0xff0100

# 0xff0100 指接收任何种类的蓝牙设备的连接;

# 0×200404 指只接收audio/video device类型的设备连接。

# Default packet type

# pkt_type DH1, DM1, HV1;

# Inquiry and Page scan

iscan enable; pscan enable;

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

}

完成之后,重启蓝牙服务:

service bluetooth stop

service bluetooth start

五、挂载蓝牙相关模块并启动蓝牙

1.挂载sco模块

cd /lib/modules/`uname -r`/kernel/net/bluetooth/

modprobe sco.ko

2.增加声音的SDP宣告

hciconfig hci0 up #这部分不做,下边的扫描无法运行

hciconfig hci0 voice 0×0060

3.扫描蓝牙并获取MAC地址

hcitool scan

4.蓝牙配对

hcitool cc 00:21:19:A4:E0:F1

5.将蓝牙耳机绑定到相应地址上

btsco bdaddress

bdaddress是蓝牙的MAC地址

连接后输入PIN码。此时,蓝牙耳机的音频设备会被映射到/dev/dsp1,可以通过ls -l /dev/dsp1查看。

六、测试与使用蓝牙耳机

1.用alsaplayer播放向蓝牙耳机播放音乐

aplay -D plughw:Headset sound.wav

按蓝牙耳机接听键

2.arecord录音

arecord -d 10 -f cd -t wav -D plughw:Headset record.wav plughw:Headset指明是从耳机播放,只是单声道的声音非常差。

你可能感兴趣的:(Linux蓝牙耳机软件)