蓝牙技术 A2DP AVRCP BlueZ

BlueZ 做为 linux 标准的协议栈,提供非常多的 profile ,各种的支持,ble , 蓝牙网络,文件传输,a2dp 音频传输。

A2DP——Advanced Audio Distribution Profile  A2DP Sink 输入设备,如蓝牙耳机。A2DP Source 输出设备,如手机。

音频压缩格式支持:其中SBC是必须支持的,可选的格式有MPEG-1, MPEG-2, MPEG-4, AAC and ATRC, 另外也支持厂商扩展的格式,比如高质量的音频编码格式apt-X。

BlueZ 编译和安装不是重点,可以看看 https://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARM

其实也可以在 虚拟机的 ubuntu 上进行验证,这里使用 raspberry Pi 3b+ 自带 WIFI + BT 功能,和一个 CSR8510 的蓝牙usb ,win10 ubuntu 系统都有驱动。

树莓派 3b+ 这个比较新,软件包是自带的 bluez 是 5.43 。

PulseAuido 提供,混音,音频路由 route ,可以让应用,同时打开多个节点。

d-bus 提供,ipc 进程间通讯。

bluez 还依赖 glib2.0 , glib2.0 是 gtk 的一个项目。

glib2.0 提供很多实用的功能,事件,线程,定时器等,很多功能。

hciconfig 查看蓝牙适配器 * 是打码。

hci1:    Type: Primary  Bus: UART
    BD Address: *********  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING 
    RX bytes:855 acl:0 sco:0 events:60 errors:0
    TX bytes:4247 acl:0 sco:0 commands:60 errors:0

hci0:    Type: Primary  Bus: USB
    BD Address: *********  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING 
    RX bytes:1256 acl:0 sco:0 events:78 errors:0
    TX bytes:3776 acl:0 sco:0 commands:78 errors:0

新的工具 bluetoothctl

info *:*:*:*:*:*
Device *:*:*:*:*:* (public)
    Name: 小米手机
    Alias: 小米手机
    Class: 0x005a020c
    Icon: phone
    Paired: no
    Trusted: no
    Blocked: no
    Connected: no
    LegacyPairing: no
    UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
    UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
    UUID: PANU                      (00001115-0000-1000-8000-00805f9b34fb)
    UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
    UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
    UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
    UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
    UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)

info *:*:*:*:*:*
Device *:*:*:*:*:* (public)
    Name: 坚果 Pro
    Alias: 坚果 Pro
    Class: 0x005a020c
    Icon: phone
    Paired: no
    Trusted: no
    Blocked: no
    Connected: no
    LegacyPairing: no
    UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
    UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
    UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
    UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
    UUID: SIM Access                (0000112d-0000-1000-8000-00805f9b34fb)
    UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
    UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)

可以看出来,2个手机的,Class 是一样的,提供的服务也是一样的  UUID 

几个重要的问题

1,如何配对

2,接收到的数码如何解码

3,如何播放 

 

posted @ 2019-01-26 21:26  宁次  阅读(2084)  评论(0编辑  收藏  举报