2014年8月3日 星期日

[ Android ] : bluetooth HCI log ( >= android 4.3)


After android 4.2, the bluetooth stack was changed from bluez to bluedroid;
so... the log tool ( hci tools ) was abandoned.

But you can still get BT log by thess 3 steps :

1. enable BT HCI logger at "settings > developer" :

2. modify the log level you want trace :

a. the location of configure file at /etc/bluetooth/bt_stack.conf

b. then modify the file content:
============================================================
# Enable BtSnoop logging function
# valid value : true, false
BtSnoopLogOutput=false

# BtSnoop log output file
BtSnoopFileName=/sdcard/btsnoop_hci.log

# Enable trace level reconfiguration function
# Must be present before any TRC_ trace level settings
TraceConf=true

# Trace level configuration
#   BT_TRACE_LEVEL_NONE    0    ( No trace messages to be generated )
#   BT_TRACE_LEVEL_ERROR   1    ( Error condition trace messages )
#   BT_TRACE_LEVEL_WARNING 2    ( Warning condition trace messages )
#   BT_TRACE_LEVEL_API     3    ( API traces )
#   BT_TRACE_LEVEL_EVENT   4    ( Debug messages for events )
#   BT_TRACE_LEVEL_DEBUG   5    ( Full debug messages )
#   BT_TRACE_LEVEL_VERBOSE 6    ( Verbose messages ) - Currently supported for TRC_BTAPP only.
TRC_BTM=2
TRC_HCI=2
TRC_L2CAP=2
TRC_RFCOMM=2
TRC_OBEX=2
TRC_AVCT=2
TRC_AVDT=2
TRC_AVRC=2
TRC_AVDT_SCB=2
TRC_AVDT_CCB=2
TRC_A2D=2
TRC_SDP=2
TRC_GATT=2
============================================================
you should change BtSnoopLogOutput=false >> BtSnoopLogOutput=true
and change the log level you interest, like : TRC_L2CAP=2 >> TRC_L2CAP=5
notice that the output log file at /sdcard/btsnoop_hci.log

3. read your output log file by wireshark :