linux bluetooth

一 、底層kernel的配置情況
[*] Networking support —>
/Unix socket配置/
Networking options —>
<*> Unix domain sockets
/* Bluetooth子系統配置 */
<*> Bluetooth subsystem support —>
<*> L2CAP protocol suppor
<*> SCO links support
<*> RFCOMM protocol support
[*] RFCOMM TTY support
<*> BNEP protocol support
[*] Multicast filter support
[*] Protocol filter support
<*> HIDP protocol support
Bluetooth device drivers —>
<*> HCI UART driver
[*] UART (H4) protocol support
[ ] BCSP protocol support
[ ] Atheros AR300x serial support
[*] HCILL protocol support
< > HCI VHCI (Virtual HCI device) driver
< > Marvell Bluetooth driver support
/* RF switch 子系統配置 */
<*> RF switch subsystem support —>
[*] Power off on suspend
[*] RF switch input support
/藍牙misc設備配置/
Device Drivers —>
[*] Misc devices —>
<*> Bluetooth power control driver
<*> BCM module power control core driver
/UART0配置/
Character devices —>
Serial drivers —>
[*] enable uart0
[ ] enable uart0 dma mode

二、啓動藍牙的腳本
#!/bin/sh

echo 1 > /sys/class/rfkill/rfkill0/state (setting中開關狀態)
brcm_patchram_plus –patchram /usr/etc/bluetooth/bcm43341.hcd –baudrate 3000000 –enable_hci –bd_addr 11:11:11:11:11:11 – tosleep=5000 –no2bytes /dev/ttyS0
( brcm_patchram_plus 命令是藍牙芯片廠商博通提供的,將固件加載到芯片中,初始化芯片用,後面配波特率,接着配串口(uart),通過uart加載到藍牙芯片中,這個段程序在android中的external//bluetooth/bluedroid 再到 hardware/broadcom/libbt/src/hardware.c,也就是上層通過層層調用最後執行到這裏)
hciattach -s 3000000 /dev/ttyS0 any 3000000
(ttyS0走哪個串口由kernel來配置)
rfkill unblock all (解鎖)
hciconfig hci0 up (激活藍牙,上電,hci0是套接字,底層走pmu供電,藍牙打不開問題跟底層串口配置有關)
bluetoothd –udev (bluez協議棧) 啓動協議棧守護進程
sleep 2
hciconfig hci0 reset

hcitool cmd 0x03 0x001A 0x03 (使藍牙設備可見,執行這步時會走bluez,藍牙搜索不到問題有關)

#close bluetooth
# hciconfig hci0 down

(1)其中hcittach 命令的源碼在bluez/tools/hciconfig.c
藍牙設備(IC)與CPU之間,它們之間的接口稱爲 HCI

(2)L2CAP Logical Link Control and Adaptation Protocol 實現藍牙數據包分割和重組,信息傳遞服務質量,可以理解爲是藍牙的網絡層協議,主要在Linux主要由驅動來實現。

(3)HCI只是提出一個抽象的邏輯接口,具體藍牙設備與CPU互聯還是需要特定的硬件方式.
最常見的是USB聯接,市面常見USB藍牙棒即是此類接口。
還有UART串口形式的藍牙設備。

三、M200芯片內部原理圖:
這裏寫圖片描述

bt芯片的驅動是bcm43341.hcd,
藍牙通過uart和CPU通信。上層是bluez協議棧。

四、android藍牙結構圖
這裏寫圖片描述

發佈了35 篇原創文章 · 獲贊 8 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章