我按照页面Bluetooth Low Energy开发Android 4.3的蓝牙低功耗。
我已经可以打开蓝牙,扫描设备并连接到BLE设备。
但是,在尝试连接到device(device.connectGatt)并且发现BLE设备的服务(mBluetoothGatt.discoverServices)之前,它会显示BluetoothGatt : android.os.DeadObjectException。
在BluetoothGatt : android.os.DeadObjectException之前,它显示如下的日志
W/bt-smp (10670): io_cap = 4
W/bt-smp (10670): new io_cap = 4 p_cb->loc_enc_size = 16
W/BluetoothEventManager( 7380): CachedBluetoothDevice for device 20:73:20:00:6C:B4 not found, calling readPairedDevices().
D/BluetoothAdapterService(1108123608)(10670): Get Bonded Devices being called
E/BluetoothEventManager( 7380): Got bonding state changed for 20:73:20:00:6C:B4, but we have no record of that device.在发现服务之前连接到BLE设备时的完整日志如下所示
I/BluetoothLeService(10888): BluetoothGattCallback-----newState = 2
I/BluetoothLeService(10888): STATE_CONNECTED:
I/Device_information(10888): BroadcastReceiver---action = ti.android.ble.common.ACTION_GATT_CONNECTED
W/qdhwcomposer( 326): Excessive delay reading vsync: took 816 ms
I/BluetoothBondStateMachine(10670): Bond address is:20:73:20:00:6C:B4
I/BluetoothBondStateMachine(10670): Entering PendingCommandState State
I/BluetoothBondStateMachine(10670): bondStateChangeCallback: Status: 0 Address: 20:73:20:00:6C:B4 newState: 1
D/BluetoothAdapterService(1108123608)(10670): Get Bonded Devices being called
I/BluetoothBondStateMachine(10670): Bond State Change Intent:20:73:20:00:6C:B4 OldState: 10 NewState: 11
W/bt-smp (10670): io_cap = 4
W/bt-smp (10670): new io_cap = 4 p_cb->loc_enc_size = 16
W/BluetoothEventManager( 7380): CachedBluetoothDevice for device 20:73:20:00:6C:B4 not found, calling readPairedDevices().
D/BluetoothAdapterService(1108123608)(10670): Get Bonded Devices being called
E/BluetoothEventManager( 7380): Got bonding state changed for 20:73:20:00:6C:B4, but we have no record of that device.
E/BluetoothGatt( 8804):
E/BluetoothGatt( 8804): android.os.DeadObjectException
E/BluetoothGatt( 8804): at android.os.BinderProxy.transact(Native Method)
E/BluetoothGatt( 8804): at android.bluetooth.IBluetoothGatt$Stub$Proxy.clientConnect(IBluetoothGatt.java:739)
E/BluetoothGatt( 8804): at android.bluetooth.BluetoothGatt.connect(BluetoothGatt.java:715)
E/BluetoothGatt( 8804): at com.sonyericsson.extras.liveware.aas.AasGatt.connect(AasGatt.java:144)
E/BluetoothGatt( 8804): at com.sonyericsson.extras.liveware.aas.AasGatt.onStartCommand(AasGatt.java:105)
E/BluetoothGatt( 8804): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2768)
E/BluetoothGatt( 8804): at android.app.ActivityThread.access$1900(ActivityThread.java:150)
E/BluetoothGatt( 8804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1395)
E/BluetoothGatt( 8804): at android.os.Handler.dispatchMessage(Handler.java:99)
E/BluetoothGatt( 8804): at android.os.Looper.loop(Looper.java:213)
E/BluetoothGatt( 8804): at android.app.ActivityThread.main(ActivityThread.java:5225)
E/BluetoothGatt( 8804): at java.lang.reflect.Method.invokeNative(Native Method)
E/BluetoothGatt( 8804): at java.lang.reflect.Method.invoke(Method.java:525)
E/BluetoothGatt( 8804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
E/BluetoothGatt( 8804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
E/BluetoothGatt( 8804): at dalvik.system.NativeStart.main(Native Method)
D/BluetoothGatt( 8804): connect() - device: 20:73:20:00:6C:B4, auto: false
D/BluetoothGatt( 8804): registerApp()
D/BluetoothGatt( 8804): registerApp() - UUID=3a123b89-8939-4d5b-ae6b-3ca1d98b4208
D/BtGatt.GattService(10670): registerClient() - UUID=3a123b89-8939-4d5b-ae6b-3ca1d98b4208
D/BtGatt.btif(10670): btif_gattc_register_app
D/BtGatt.btif(10670): btgattc_handle_event: Event 1000
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 0
D/BtGatt.GattService(10670): onClientRegistered() - UUID=3a123b89-8939-4d5b-ae6b-3ca1d98b4208, clientIf=5
E/MP-Decision( 2172): Error setting a sleep mode for secondary cores - -38
D/BluetoothGatt( 8804): onClientRegistered() - status=0 clientIf=5
D/BtGatt.GattService(10670): clientConnect() - address=20:73:20:00:6C:B4, isDirect=true
D/BtGatt.btif(10670): btif_gattc_open
D/BtGatt.btif(10670): btgattc_handle_event: Event 1004
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 2
D/BtGatt.GattService(10670): onConnected() - clientIf=5, connId=5, address=20:73:20:00:6C:B4
D/BluetoothGatt( 8804): onClientConnectionState() - status=0 clientIf=5 device=20:73:20:00:6C:B4
D/BluetoothGatt( 8804): discoverServices() - device: 20:73:20:00:6C:B4
D/BtGatt.GattService(10670): discoverServices() - address=20:73:20:00:6C:B4, connId=5
D/BtGatt.btif(10670): btif_gattc_search_service
D/BtGatt.btif(10670): btgattc_handle_event: Event 1006
V/BluetoothMasReceiver( 8128): BluetoothMasReceiver onReceive :android.bluetooth.device.action.BOND_STATE_CHANGED
V/BluetoothMasService( 8128): Map Service onStartCommand
V/BluetoothMasService( 8128): action: android.bluetooth.device.action.BOND_STATE_CHANGED
W/bt-smp (10670): loca