配对日志:
05-09 20:36:50.481 5055 5055 I BluetoothDevice: createBond() for device 7C:DF:A1:E2:71:6E called by pid: 5055 tid: 5055
05-09 20:36:50.484 6646 6657 D A2dpService: getA2DPService(): returning com.android.bluetooth.a2dp.A2dpService@f9f3c27
05-09 20:36:50.484 6646 6657 I bt_btif : btif_dm_cancel_discovery
05-09 20:36:50.484 6646 6732 I bt_btif : BTA got event 0x201
05-09 20:36:50.484 6646 6732 I bt_btif : bta_dm_search_sm_execute state:0, event:0x201
05-09 20:36:50.484 6646 6732 D bt_btif : bte_search_devices_evt event=BTA_DM_SEARCH_CANCEL_CMPL_EVT param_len=0
05-09 20:36:50.484 6646 6732 D bt_btif : btif_transfer_context event 6, len 0
05-09 20:36:50.484 6646 6732 I bt_btm : BTM_CancelRemoteDeviceName()
05-09 20:36:50.486 6646 6666 D bt_btif : btif task fetched event a001
05-09 20:36:50.486 6646 6666 D bt_btif : btif_context_switched
05-09 20:36:50.486 6646 6666 I bt_btif : btif_dm_search_devices_evt event=BTA_DM_SEARCH_CANCEL_CMPL_EVT
05-09 20:36:50.486 6646 6666 I bt_btif : BTA_DmBleScanFilterSetup: 1
05-09 20:36:50.486 6646 6666 I bt_btif : HAL bt_hal_cbacks->discovery_state_changed_cb
05-09 20:36:50.486 6646 6732 I bt_btif : BTA got event 0x123
05-09 20:36:50.486 6646 6732 I bt_btif : bta_dm_sm_execute event:0x23
05-09 20:36:50.486 6646 6732 D bt_btif : bta_dm_scan_filter_param_setup
05-09 20:36:50.486 6646 6732 D bt_btm : BTM_BleGetVendorCapabilities
05-09 20:36:50.486 6646 6732 D bt_btm : BTM_BleGetVendorCapabilities
05-09 20:36:50.486 6646 6732 I bt_btm : BTM_BleAdvFilterParamSetup
05-09 20:36:50.486 6646 6732 I bt_btm : BTM: BTM_VendorSpecificCommand: Opcode: 0xFD57, ParamLen: 3.
05-09 20:36:50.486 6646 6732 D bt_btm : btm_ble_advfilt_enq_op_q: act_ocf:17, action:1, ocf:1,cb_evt;3, cback:0
05-09 20:36:50.488 6646 6667 I BluetoothBondStateMachine: Bond address is:7C:DF:A1:E2:71:6E
05-09 20:36:50.488 6646 6667 I bt_btif : btif_dm_create_bond: bd_addr=7c:df:a1:e2:71:6e, transport=0
05-09 20:36:50.488 6646 6667 D bt_btif_config: btif_get_device_type: Device [7c:df:a1:e2:71:6e] type 2
05-09 20:36:50.488 6646 6667 D bt_btif : in, bd addr:7c:df:a1:e2:71:6e, prop type:4, len:4
05-09 20:36:50.488 6646 6667 I bt_btif_dm: get_cod remote_cod = 0x00001f00
05-09 20:36:50.489 6646 6667 D bt_btif : btif_transfer_context event 33026, len 6
05-09 20:36:50.489 6646 6667 I BluetoothBondStateMachine: Entering PendingCommandState State
05-09 20:36:50.490 6646 6666 D bt_btif : btif task fetched event a001
05-09 20:36:50.490 6646 6666 D bt_btif : btif_context_switched
05-09 20:36:50.490 6646 6666 I bt_btif : btif_dm_generic_evt: event=33026
05-09 20:36:50.490 5055 6627 D Index : Indexing locale 'zh_CN' took 3 millis
05-09 20:36:50.490 6646 6666 D bt_btif : in, bd addr:7c:df:a1:e2:71:6e, prop type:4, len:4
05-09 20:36:50.490 6646 6666 I bt_btif_dm: get_cod remote_cod = 0x00001f00
05-09 20:36:50.490 6646 6666 D bt_btif_config: btif_get_device_type: Device [7c:df:a1:e2:71:6e] type 2
05-09 20:36:50.490 6646 6666 D bt_btif : in, bd addr:7c:df:a1:e2:71:6e, prop type:4, len:4
05-09 20:36:50.490 6646 6666 I bt_btif_dm: get_cod remote_cod = 0x00001f00
05-09 20:36:50.490 6646 6666 D bt_btif : bond_state_changed: state=1, prev_state=0, sdp_attempts = 0
05-09 20:36:50.490 6646 6666 I bt_btif : HAL bt_hal_cbacks->bond_state_changed_cb
05-09 20:36:50.491 569 1064 D msm8916_platform: platform_set_channel_map mixer_ctl_name:Playback Channel Map12
05-09 20:36:50.491 6646 6666 I BluetoothBondStateMachine: bondStateChangeCallback: Status: 0 Address: 7C:DF:A1:E2:71:6E newState: 1
01-01 10:28:09.523 3577 3753 I BluetoothBondStateMachine: bondStateChangeCallback: Status: 1 Address: 7C:DF:A1:E2:44:B6 newState: 0
01-01 10:28:09.524 3577 4041 D BluetoothAdapterProperties: Failed to remove device: 7C:DF:A1:E2:44:B6
01-01 10:28:09.526 3577 3577 D BluetoothDunService: parseIntent: action: android.bluetooth.device.action.BOND_STATE_CHANGED
01-01 10:28:09.528 3577 4041 I BluetoothBondStateMachine: Bond State Change Intent:7C:DF:A1:E2:44:B6 OldState: 11 NewState: 10 配对失败
连接日志
BtGatt.GattService: onConnected() - clientIf=5, connId=5, address=7C:DF:A1:E2:45:4A
BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=7C:DF:A1:E2:45:4A
在文件system/bt/bta/include/bta_gatt_api.h 成功码和失败码的定义
/* Success code and error codes */
#define BTA_GATT_OK GATT_SUCCESS
#define BTA_GATT_INVALID_HANDLE GATT_INVALID_HANDLE /* 0x0001 */
#define BTA_GATT_READ_NOT_PERMIT GATT_READ_NOT_PERMIT /* 0x0002 */
#define BTA_GATT_WRITE_NOT_PERMIT GATT_WRITE_NOT_PERMIT /* 0x0003 */
#define BTA_GATT_INVALID_PDU GATT_INVALID_PDU /* 0x0004 */
#define BTA_GATT_INSUF_AUTHENTICATION GATT_INSUF_AUTHENTICATION /* 0x0005 */
#define BTA_GATT_REQ_NOT_SUPPORTED GATT_REQ_NOT_SUPPORTED /* 0x0006 */
#define BTA_GATT_INVALID_OFFSET GATT_INVALID_OFFSET /* 0x0007 */
#define BTA_GATT_INSUF_AUTHORIZATION GATT_INSUF_AUTHORIZATION /* 0x0008 */
#define BTA_GATT_PREPARE_Q_FULL GATT_PREPARE_Q_FULL /* 0x0009 */
#define BTA_GATT_NOT_FOUND GATT_NOT_FOUND /* 0x000a */
#define BTA_GATT_NOT_LONG GATT_NOT_LONG /* 0x000b */
#define BTA_GATT_INSUF_KEY_SIZE GATT_INSUF_KEY_SIZE /* 0x000c */
#define BTA_GATT_INVALID_ATTR_LEN GATT_INVALID_ATTR_LEN /* 0x000d */
#define BTA_GATT_ERR_UNLIKELY GATT_ERR_UNLIKELY /* 0x000e */
#define BTA_GATT_INSUF_ENCRYPTION GATT_INSUF_ENCRYPTION /* 0x000f */
#define BTA_GATT_UNSUPPORT_GRP_TYPE GATT_UNSUPPORT_GRP_TYPE /* 0x0010 */
#define BTA_GATT_INSUF_RESOURCE GATT_INSUF_RESOURCE /* 0x0011 */
#define BTA_GATT_NO_RESOURCES GATT_NO_RESOURCES /* 0x80 */
#define BTA_GATT_INTERNAL_ERROR GATT_INTERNAL_ERROR /* 0x81 */
#define BTA_GATT_WRONG_STATE GATT_WRONG_STATE /* 0x82 */
#define BTA_GATT_DB_FULL GATT_DB_FULL /* 0x83 */
#define BTA_GATT_BUSY GATT_BUSY /* 0x84 */
#define BTA_GATT_ERROR GATT_ERROR /* 0x85 */
framework 中涉及文件
frameworks/base/core/java/android/bluetooth/BluetoothGatt.java
connect->registerApp(callback, handler)->onClientConnectionState