1 蓝牙搜索
bt_btif : btif_dm_start_discovery : pairing_cb.state: 0x0
bt_btif : bta_sys_event: Event 0x200
bt_btif : bta_dm_search_sm_execute state:0, event:0x200
bt_btif : bta_dm_search_start avoid_scatter=1
bt_btif : bta_dm_search_start status=1
2 配对
BluetoothDevice: createBond() for device 1C:52:16:6E:AA:E5 called by pid: 10769 tid: 10769
bt_btif : btif_dm_create_bond: bd_addr=1c:52:16:6e:aa:e5, transport=0
BluetoothBondStateMachine: Bond address is:1C:52:16:6E:AA:E5
BluetoothBondStateMachine: Entering PendingCommandState State
BluetoothBondStateMachine: bondStateChangeCallback: Status: 0 Address: 1C:52:16:6E:AA:E5 newState: 1
BluetoothBondStateMachine: Bond State Change Intent:1C:52:16:6E:AA:E5 OldState: 10 NewState: 11
BluetoothBondStateMachine: sspRequestCallback: [B@e37d1cf name: [B@4cb975c cod: 2360324 pairingVariant 2 passkey: 259628
3 蓝牙发送文件
BluetoothOppReceiver: Action :android.bluetooth.devicepicker.action.DEVICE_SELECTED
//选择远端设备
BtOppTransfer: Action :android.bluetooth.device.action.SDP_RECORD
BtOppTransfer: Aaron: Received UUID: 00001105-0000-1000-8000-00805f9b34fb
BtOppTransfer: Aaron: expected UUID: 00001105-0000-1000-8000-00805f9b34fb
// 搜索出来远端设备的UUID, 1105,表示远端设备支持OPP协议
BtOppObexClient: Remote accept
// 远端设备接收。
4 蓝牙接收文件
ObexServerSockets2: Accepting socket connection...
ObexServerSockets2: Accepted socket connection from: ServerSocket: Type: TYPE_L2CAP Channel: 4131
接受socket的连接请求,选择L2CAP作为传输通道
BtOppObexServer: Aaron: Create ServerSession with transport com.android.bluetooth.BluetoothObexTransport@bb5a7f0
BtOppObexServer: Aaron: onConnect
BtOppObexServer: Aaron: onPut javax.obex.ServerOperation@5f8248f
BtOppObexServer: Aaron: onPut(), name = IMG_20180207_050410.jpg, length = 561910, mimeType = image/jpeg
//开始接收
BtOppObexServer: onDisconnect
BtOppObexServer: onClose
//接收完成
5 蓝牙耳机听歌
A2dpStateMachine: Connection state 94:CE:2C:F9:63:CB: 0->1
A2dpStateMachine: Connection state 94:CE:2C:F9:63:CB: 1->2
状态从0变为1,从1变为2,当变为2的时候,表示蓝牙耳机已经连接上
APM_AudioPolicyManager: setOutputDevice() device 0080 delayMs 0
音频通道的口选择为0x80,表示是a2dp
bt_a2dp_hw: start_audio_datapath: state 5
bt_a2dp_hw: start_audio_datapath: state AUDIO_A2DP_STATE_STANDBY
bt_a2dp_hw: a2dp_command: A2DP COMMAND A2DP_CTRL_CMD_START, fail count 0
// 给btif下发start的命令
btif_a2dp_ctrl_cb: A2DP-CTRL-CHANNEL EVENT UIPC_RX_DATA_READY_EVT
btif_a2dp_recv_ctrl_data: A2DP_CTRL_CMD_START
create_server_socket /data/misc/bluedroid/.a2dp_data
// 当收到start的命令的时候,注册data的socket的通道
bta_sys_event: Event 0x1231
bta_av_co_audio_src_data_path: codec: SBC
bta_av_dup_audio_buf: data not to dup
// sbc格式的编码
AVDT_WriteReqOpt: handle=1 timestamp=0 m_pt=0x60 opt=0x0
L2CA_DataWrite() CID: 0x004d Len: 608
// 将数据写到L2CAP层
A2dpStateMachine: A2DP Playing state : device: 94:CE:2C:F9:63:CB State:11->10
状态从11变为10, 表示音乐处于播放状态。
6 蓝牙耳机打电话
HeadsetStateMachine: Connection state 94:CE:2C:F9:63:CB: 0->1
HeadsetStateMachine: Connection state 94:CE:2C:F9:63:CB: 1->2
状态从0变为1,从1变为2,当变为2的时候,表示蓝牙耳机已经连接上
APM_AudioPolicyManager: setOutputDevice() device 0020 delayMs 100
音频通道的口选择为0x20,表示是sco
HeadsetStateMachine: Audio state 94:CE:2C:F9:63:CB: 11->12
Audio的状态变为12, 表示电话接通
HeadsetStateMachine: Audio state 94:CE:2C:F9:63:CB: 12->10
Audio的状态变为11, 表示电话被挂断
蓝牙耳机连接之后,HFP里面最基本的三个AT指令,AT+BRSF, AT+CIND=?, AT+CIND?