藍牙技術 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,如何播放 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM