如何解决BluetoothGatt:在Android中发生android.os.DeadObjectException错误? [英] How to solve the BluetoothGatt : android.os.DeadObjectException error happened in Android?
问题描述
我下面的网页。蓝牙低耗能的开发中 Android 4.3的对于蓝牙低功耗
我已经可以打开蓝牙,扫描设备,并连接到BLE装置。
但它显示 BluetoothGatt:android.os.DeadObjectException
之后,我尝试连接到设备 (设备。 connectGatt)
和之前发现的服务 (mBluetoothGatt.discoverServices)
的BLE设备。
在 BluetoothGatt:android.os.DeadObjectException
它显示日志类似于以下
W / BT-SMP(10670):io_cap = 4
W / BT-SMP(10670):新io_cap = 4 p_cb-> loc_enc_size = 16
W / BluetoothEventManager(7380):CachedBluetoothDevice用于设备20:73:20:00:6C:B4没有找到,调用readPairedDevices()。
D / BluetoothAdapterService(1108123608)(10670):获取绑定设备被称为
E / BluetoothEventManager(7380):73:20:00:6C:GOT粘合状态改变20 B4,但我们没有该设备的记录。
完整的记录,当我的连接到BLE装置发现服务是像下面的
在 I / BluetoothLeService(10888):BluetoothGattCallback ----- newState = 2
I / BluetoothLeService(10888):STATE_CONNECTED:
I / Device_information(10888):广播接收器---行动= ti.android.ble.common.ACTION_GATT_CONNECTED
W / qdhwcomposer(326):过多的延迟阅读VSYNC:816了MS
I / BluetoothBondStateMachine(10670):债券地址为:20:73:20:00:6C:B4
I / BluetoothBondStateMachine(10670):输入PendingCommandState国家
I / BluetoothBondStateMachine(10670):bondStateChangeCallback:状态:0地址:20:73:20:00:6C:B4 newState:1
D / BluetoothAdapterService(1108123608)(10670):获取绑定设备被称为
I / BluetoothBondStateMachine(10670):邦德状态更改意向:20:73:20:00:6C:B4 OldState:10 NewState:11
W / BT-SMP(10670):io_cap = 4
W / BT-SMP(10670):新io_cap = 4 p_cb-> loc_enc_size = 16
W / BluetoothEventManager(7380):CachedBluetoothDevice用于设备20:73:20:00:6C:B4没有找到,调用readPairedDevices()。
D / BluetoothAdapterService(1108123608)(10670):获取绑定设备被称为
E / BluetoothEventManager(7380):73:20:00:6C:GOT粘合状态改变20 B4,但我们没有该设备的记录。
E / BluetoothGatt(8804):
E / BluetoothGatt(8804):android.os.DeadObjectException
E / BluetoothGatt(8804):在android.os.BinderProxy.transact(本机方法)
E / BluetoothGatt(8804):在android.bluetooth.IBluetoothGatt $存根$ Proxy.clientConnect(IBluetoothGatt.java:739)
E / BluetoothGatt(8804):在android.bluetooth.BluetoothGatt.connect(BluetoothGatt.java:715)
E / BluetoothGatt(8804):在com.sonyericsson.extras.liveware.aas.AasGatt.connect(AasGatt.java:144)
E / BluetoothGatt(8804):在com.sonyericsson.extras.liveware.aas.AasGatt.onStartCommand(AasGatt.java:105)
E / BluetoothGatt(8804):在android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2768)
E / BluetoothGatt(8804):在android.app.ActivityThread.access $ 1900年(ActivityThread.java:150)
E / BluetoothGatt(8804):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1395)
E / BluetoothGatt(8804):在android.os.Handler.dispatchMessage(Handler.java:99)
E / BluetoothGatt(8804):在android.os.Looper.loop(Looper.java:213)
E / BluetoothGatt(8804):在android.app.ActivityThread.main(ActivityThread.java:5225)
E / BluetoothGatt(8804):在java.lang.reflect.Method.invokeNative(本机方法)
E / BluetoothGatt(8804):在java.lang.reflect.Method.invoke(Method.java:525)
E / BluetoothGatt(8804):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:741)
E / BluetoothGatt(8804):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
E / BluetoothGatt(8804):在dalvik.system.NativeStart.main(本机方法)
D / BluetoothGatt(8804):连接() - 设备:20:73:20:00:6C:B4,自动:假的
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:事件1000
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件0
D / BtGatt.GattService(10670):onClientRegistered() - UUID = 3a123b89-8939-4d5b-ae6b-3ca1d98b4208,clientIf = 5
E / MP-决定(2172):错误设置睡眠模式进行二次核 - -38
D / BluetoothGatt(8804):onClientRegistered() - 状态= 0 clientIf = 5
D / BtGatt.GattService(10670):clientConnect() - 地址= 20:73:20:00:6C:B4,isDirect =真
D / BtGatt.btif(10670):btif_gattc_open
D / BtGatt.btif(10670):btgattc_handle_event:事件1004
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件2
D / BtGatt.GattService(10670):onConnected() - clientIf = 5,CONNID = 5,地址= 20:73:20:00:6C:B4
D / BluetoothGatt(8804):onClientConnectionState() - 状态= 0 clientIf = 5设备= 20:73:20:00:6C:B4
D / BluetoothGatt(8804):discoverServices() - 设备:20:73:20:00:6C:B4
D / BtGatt.GattService(10670):discoverServices() - 地址= 20:73:20:00:6C:B4,CONNID = 5
D / BtGatt.btif(10670):btif_gattc_search_service
D / BtGatt.btif(10670):btgattc_handle_event:事件1006
V / BluetoothMasReceiver(8128):BluetoothMasReceiver的onReceive:android.bluetooth.device.action.BOND_STATE_CHANGED
V / BluetoothMasService(8128):地图服务onStartCommand
V / BluetoothMasService(8128):动作:android.bluetooth.device.action.BOND_STATE_CHANGED
W / BT-SMP(10670):本地兰特(LSB〜MSB)= 86 FE B8 98 D9 17 EC 85 11 5C 06 18 19 72 99 CF
W / BT-SMP(10670):P1(LSB〜MSB)= 00 00 01 04 00 05 10 07 07 02 03 00 01 10 07 07
W / BT-SMP(10670):P1'= R XOR P1(LSB〜MSB)= 86 FE B9 9C D9 FC 12 16 82 05 5E 18 18 62 9E C8
W / BT-SMP(10670):密钥(LSB〜MSB)= 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):纯文本(LSB〜MSB)= 86 FE B9 9C D9 FC 12 16 82 05 5E 18 18 62 9E C8
W / BT-SMP(10670):加密文本(LSB〜MSB)= 09 51 07 24 65 D0 6D A0 B2 63 57 60 AA 28 29 BA
W / BT-SMP(10670):C1(LSB〜MSB)= 09 51 07 24 65 D0 6D A0 B2 63 57 60 AA 28 29 BA
W / BT-SMP(10670):P2(LSB〜MSB)= B4 6C 00 20 73 20 C5 93 40 62 51 D0 00 00 00 00
W / BT-SMP(10670):P2 = C1 XOR P2(LSB〜MSB)= BD 3D 07 04 16 F0 A8 33 F2 01 06 60 7A 28 29 BA
W / BT-SMP(10670):密钥(LSB〜MSB)= 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):纯文本(LSB〜MSB)= BD 3D 07 04 16 F0 A8 33 F2 01 06 60 7A 28 29 BA
W / BT-SMP(10670):加密文本(LSB〜MSB)= 20 4B 2B AB 92 CB 79 81 68日9E 62 D5交流4C 7B
W / BT-SMP(10670):确认(LSB〜MSB)= 20 4B 2B AB 92 CB 79 81 68日9E 62 D5交流4C 7B
D / BluetoothMasService(8128):设备:HelloFH
W / BT-SMP(10670):对兰特(LSB〜MSB)= 41 8D 98 57 20 2D 8F 51 18 93 4E CF 48 39 AC CF
W / BT-SMP(10670):P1(LSB〜MSB)= 00 00 01 04 00 05 10 07 07 02 03 00 01 10 07 07
W / BT-SMP(10670):P1'= R XOR P1(LSB〜MSB)= 41 8D 99 53 20 28 56 9F 91 1F 4D CF 49 29 AB C8
W / BT-SMP(10670):密钥(LSB〜MSB)= 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):纯文本(LSB〜MSB)= 41 8D 99 53 20 28 56 9F 91 1F 4D CF 49 29 AB C8
W / BT-SMP(10670):加密文本(LSB〜MSB)= B2 4C B9 C1 65 2B EC 8F 86 74 82 4B D3 CA C6 9F
W / BT-SMP(10670):C1(LSB〜MSB)= B2 4C B9 C1 65 2B EC 8F 86 74 82 4B D3 CA C6 9F
W / BT-SMP(10670):P2(LSB〜MSB)= B4 6C 00 20 73 20 C5 93 40 62 51 D0 00 00 00 00
W / BT-SMP(10670):P2 = C1 XOR P2(LSB〜MSB)= 06 20 B9 E1 16 0B 29 1C C6 16 D3 D3 9B CA C6 9F
W / BT-SMP(10670):密钥(LSB〜MSB)= 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):纯文本(LSB〜MSB)= 06 20 B9 E1 16 0B 29 1C C6 16 D3 D3 9B CA C6 9F
W / BT-SMP(10670):加密文本(LSB〜MSB)= 04 9A 63 EA A0 FB 6D 9E 91 70 65 54 6D 26 D0 E1
W / BT-SMP(10670):比较(LSB〜MSB)= 04 9A 63 EA A0 FB 6D 9E 91 70 65 54 6D 26 D0 E1
W / BT-SMP(10670):密钥(LSB〜MSB)= 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):纯文本(LSB〜MSB)= 86 FE B8 98 D9 17 EC 85 41 98 8D 20 57 8F 2D 51
W / BT-SMP(10670):加密文本(LSB〜MSB)= 4A 97 52大4F交流7E 4B 48 F1 BA 0D 33 DF 1207米72
E / BT-SMP(10670):STK生成
W / BT-SMP(10670):关键(LSB〜MSB)= 5E B8 49 86 94 24 C9 D3 79 10 96 8D F0发D6 DF
W / BT-SMP(10670):纯文本(LSB〜MSB)= C9 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):加密文本(LSB〜MSB)= DC 0B 54 34 A5 FF F1 6D 69 91 AF F4 77 DD 44 09
W / BT-SMP(10670):关键(LSB〜MSB)= 67 E6 91 62 0D 7A 29 34 59 17 92 D8 8D 9B发89
W / BT-SMP(10670):纯文本(LSB〜MSB)= D6 EC 85 B8 8C 5F 22 32 00 00 00 00 00 00 00 00
W / BT-SMP(10670):加密文本(LSB〜MSB)= CD 25 9E E0 C7 C3 C2 FE 1A 2C 7E 58 01 97 FA 17
E / BT-SMP(10670):LTK准备
W / BT-SMP(10670):smp_send_enc_info
W / BT-SMP(10670):smp_send_id_info
W / BT-SMP(10670):关键(LSB〜MSB)= 5E B8 49 86 94 24 C9 D3 79 10 96 8D F0发D6 DF
W / BT-SMP(10670):纯文本(LSB〜MSB)= C9 51 01 00 00 00 00 00 00 00 00 00 00 00 00 00
W / BT-SMP(10670):加密文本(LSB〜MSB)= 56 68 2A C9 E3 8 B8 B8 97 5C FD E8 60 93 76 66
D / Diag_Lib(507):[IMS_DEBUG] | 1035 | 535 | qpNetSelect:选择畅通,iRtn 0,错误号0,错误号[成功]
E / Diag_Lib(507):IMS_FATAL] | 251 | 535 | qvp_rtp_handle_signals IRET:0
E / Diag_Lib(507):IMS_FATAL] | 238 | 535 | qvp_rtp_handle_signals qpDplMainLoop:调用imsSignalHandler
D / Diag_Lib(507):[IMS_DEBUG] | 144 | 535 | qpDpl:imsSignalHandler
E / Diag_Lib(507):IMS_FATAL] | 155 | 535 | qpdpl:imsSignalHandler:全球数据NULL或事件列表大小为0
E / Diag_Lib(507):IMS_FATAL] | 243 | 535 | qvp_rtp_handle_signals添加读取FD:8
E / BT-BTIF(10670):未找到更多服务
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件7
D / BtGatt.GattService(10670):onSearchResult() - 地址= 20:73:20:00:6C:B4,UUID = 00001801-0000-1000-8000-00805f9b34fb
D / BluetoothGatt(8804):onGetService() - 设备= 20:73:20:00:6C:B4 UUID = 00001801-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件7
D / BtGatt.GattService(10670):onSearchResult() - 地址= 20:73:20:00:6C:B4,UUID = 00001800-0000-1000-8000-00805f9b34fb
D / BluetoothGatt(8804):onGetService() - 设备= 20:73:20:00:6C:B4 UUID = 00001800-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件7
D / BtGatt.GattService(10670):onSearchResult() - 地址= 20:73:20:00:6C:B4,UUID = 1b7e8251-2877-41c3-b46e-cf057c562023
D / BluetoothGatt(8804):onGetService() - 设备= 20:73:20:00:6C:B4 UUID = 1b7e8251-2877-41c3-b46e-cf057c562023
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件7
D / BtGatt.GattService(10670):onSearchResult() - 地址= 20:73:20:00:6C:B4,UUID = 0000180a-0000-1000-8000-00805f9b34fb
D / BluetoothGatt(8804):onGetService() - 设备= 20:73:20:00:6C:B4 UUID = 0000180a-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件7
D / BtGatt.GattService(10670):onSearchResult() - 地址= 20:73:20:00:6C:B4,UUID = 0000180f-0000-1000-8000-00805f9b34fb
D / BluetoothGatt(8804):onGetService() - 设备= 20:73:20:00:6C:B4 UUID = 0000180f-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_upstreams_evt:事件6
D / BtGatt.GattService(10670):onSearchCompleted() - CONNID = 5,状态= 0
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1007
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 133,charUuid = 5e0dae24-5e0d-adf0-409b-a23f420d6580,道具= 94
D / BtGatt.btif(10670):btif_gattc_get_included_service
D / BtGatt.btif(10670):btgattc_handle_event:事件1011
E / BtGatt.btif(10670):bta_to_btif_uuid:未知的UUID长度24028!
D / BtGatt.GattService(10670):onGetIncludedService() - 地址= 20:73:20:00:6C:B4,状态= 133,UUID = 00001801-0000-1000-8000-00805f9b34fb,inclUuid = 5e0dae24-5e0d,adf0 -409b-a23f420d6580
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1007
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a00-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a00-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a01-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a01-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 133,charUuid = 00002a01-0000-1000-8000-00805f9b34fb,道具= 2
D / BtGatt.btif(10670):btif_gattc_get_included_service
I / BT-HCl(10670):BLE HCI(n = 62)事件= 0×03)
I / BT-HCl(10670):btu_ble_ll_conn_param_upd_evt
D / BtGatt.btif(10670):btgattc_handle_event:事件1011
D / BtGatt.GattService(10670):onGetIncludedService() - 地址= 20:73:20:00:6C:B4,状态= 133,UUID = 00001800-0000-1000-8000-00805f9b34fb,inclUuid = 00002a01-0000-1000 -8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1007
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 8ac32d3f-5cb9-4d44-BEC2-ee689169f626,道具= 50
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 8ac32d3f-5cb9-4d44-BEC2,ee689169f626
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 5e9bf2a8-f93f-4481-a67e-3b2f4a07891a,道具= 10
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 5e9bf2a8-f93f-4481-a67e-3b2f4a07891a
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = d5b8304c-076a-42ce-9d1e-1c859336363f,道具= 50
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = d5b8304c-076a-42ce-9d1e-1c859336363f
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = f4bfe056-701d-4af7-A326-d2ecd00173f4,道具= 10
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = f4bfe056-701d-4af7-A326-d2ecd00173f4
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = b1736a91-c910-4ad2-ab3a-fd72cc55903d,道具= 10
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = b1736a91-c910-4ad2-ab3a-fd72cc55903d
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = ff890e61-5600-4426-88cf-090abe01d0b8,道具= 10
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = ff890e61-5600-4426-88cf,090abe01d0b8
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 74de75ce-03b7-4e62-84d0-0d229d456836,道具= 10
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 74de75ce,03b7-4e62-84d0-0d229d456836
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 133,charUuid = 74de75ce-03b7-4e62-84d0-0d229d456836,道具= 10
D / BtGatt.btif(10670):btif_gattc_get_included_service
D / BtGatt.btif(10670):btgattc_handle_event:事件1011
D / BtGatt.GattService(10670):onGetIncludedService() - 地址= 20:73:20:00:6C:B4,状态= 133,UUID = 1b7e8251-2877-41c3-b46e-cf057c562023,inclUuid = 74de75ce,03b7-4e62 -84d0-0d229d456836
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1007
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a29-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a29-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a24-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a24-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a23-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a23-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 133,charUuid = 00002a23-0000-1000-8000-00805f9b34fb,道具= 2
D / BtGatt.btif(10670):btif_gattc_get_included_service
D / BtGatt.btif(10670):btgattc_handle_event:事件1011
D / BtGatt.GattService(10670):onGetIncludedService() - 地址= 20:73:20:00:6C:B4,状态= 133,UUID = 0000180a-0000-1000-8000-00805f9b34fb,inclUuid = 00002a23-0000-1000 -8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1007
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 0,charUuid = 00002a19-0000-1000-8000-00805f9b34fb,道具= 2
D / BluetoothGatt(8804):onGetCharacteristic() - 设备= 20:73:20:00:6C:B4 UUID = 00002a19-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_characteristic
D / BtGatt.btif(10670):btgattc_handle_event:事件1008
D / BtGatt.GattService(10670):onGetCharacteristic() - 地址= 20:73:20:00:6C:B4,状态= 133,charUuid = 00002a19-0000-1000-8000-00805f9b34fb,道具= 2
D / BtGatt.btif(10670):btif_gattc_get_included_service
D / BtGatt.btif(10670):btgattc_handle_event:事件1011
D / BtGatt.GattService(10670):onGetIncludedService() - 地址= 20:73:20:00:6C:B4,状态= 133,UUID = 0000180f-0000-1000-8000-00805f9b34fb,inclUuid = 00002a19-0000-1000 -8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_descriptor
D / BtGatt.btif(10670):btgattc_handle_event:事件1009
D / BtGatt.GattService(10670):onGetDescriptor() - 地址= 20:73:20:00:6C:B4,状态= 133,descUuid = 00002a19-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_descriptor
D / BtGatt.btif(10670):btgattc_handle_event:事件1009
D / BtGatt.GattService(10670):onGetDescriptor() - 地址= 20:73:20:00:6C:B4,状态= 133,descUuid = 00002a19-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_descriptor
D / BtGatt.btif(10670):btgattc_handle_event:事件1009
D / BtGatt.GattService(10670):onGetDescriptor() - 地址= 20:73:20:00:6C:B4,状态= 0,descUuid = 00002902-0000-1000-8000-00805f9b34fb
D / BluetoothGatt(8804):onGetDescriptor() - 设备= 20:73:20:00:6C:B4 UUID = 00002902-0000-1000-8000-00805f9b34fb
D / BtGatt.btif(10670):btif_gattc_get_descriptor
D / BtGatt.btif(10670):btgattc_handle_event:事件1010
我不知道为什么 E / BluetoothGatt(8804):android.os.DeadObjectException
发生。
在此之后发生错误,我不能当我运行发现的BLE设备服务 mBluetoothGatt.discoverServices
。
我要断开并重新连接到BLE装置。它做工精细。
如果我清理蓝牙数据在Android的设置,并连接到BLE装置再次。
该错误再次发生...
和有时它会连接后立即断开,所以我必须要重新连接。
是否有人有相同的错误或条件?
请帮我或教我如何解决这个问题,那几日迷茫......
在此先感谢!
--------------------------------------------------EDIT-----------------------------------------------
服务的code是这样的:
包com.ampak.pace;
公共类BluetoothLeService延伸服务{ 静态最后弦乐TAG =BluetoothLeService;
私有静态BluetoothAdapter mBluetoothAdapter = NULL;
私有静态BluetoothManager mBluetoothManager = NULL;
私人BluetoothGatt mBluetoothGatt = NULL;
私人字符串mBluetoothDeviceAddress;
私人BluetoothDevice类设备;
公共静态字符串地址= NULL;
公共静态处理程序处理程序=新的处理程序(Looper.getMainLooper());
私人最终BluetoothGattCallback mGattCallback =新BluetoothGattCallback(){ 公共无效onConnectionStateChange(GATT android.bluetooth.BluetoothGatt,诠释状态,诠释newState){
如果(mBluetoothGatt == NULL){
Log.e(TAGmBluetoothGatt没有创建!);
返回;
} 设备= gatt.getDevice();
地址= device.getAddress(); 尝试{
开关(newState){
案例BluetoothAdapter.STATE_CONNECTED: Log.i(TAG,STATE_CONNECTED:);
broadcastUpdate(ACTION_GATT_CONNECTED,设备状态);
打破;
案例BluetoothAdapter.STATE_DISCONNECTED:
Log.i(TAG,STATE_DISCONNECTED:);
gatt.close();
broadcastUpdate(ACTION_GATT_DISCONNECTED,设备状态);
打破; 默认:
Log.i(TAG,新状态不处理:+ newState);
打破;
}
}赶上(例外五){
// TODO:处理异常
e.printStackTrace();
}
}
公共无效onCharacteristicRead(GATT BluetoothGatt,BluetoothGattCharacteristic特征,诠释状态){
如果(状态== BluetoothGatt.GATT_SUCCESS){
}
}; 公共无效onServicesDiscovered(GATT BluetoothGatt,诠释状态){
如果(状态== BluetoothGatt.GATT_SUCCESS){
Log.i(TAGonServicesDiscovered ----- GATT_SUCCESS @@@@@@ =);
}
};
};
私人无效broadcastUpdate(最后字符串的动作,最终BluetoothDevice类设备,最终诠释状态){
// TODO自动生成方法存根
最终意向意图=新意图(动作);
intent.putExtra(EXTRA_UUID,装置);
intent.putExtra(EXTRA_STATUS,地位); sendBroadcast(意向);
} 公共布尔初始化(){
// TODO自动生成方法存根
如果(mBluetoothManager == NULL){
Log.e(TAGBluetoothManager初始化@@@);
mBluetoothManager =(BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE);
如果(mBluetoothManager == NULL){
Log.e(TAG,无法初始化BluetoothManager);
返回false;
}
} mBluetoothAdapter = mBluetoothManager.getAdapter();
如果(mBluetoothAdapter == NULL){
Log.e(TAG,无法获得BluetoothAdapter);
返回false;
}
返回true;
} 公共无效连接(最后弦乐地址){
// TODO自动生成方法存根
Log.w(TAGBluetoothLeService连接功能。);
如果(mBluetoothAdapter == NULL ||地址== NULL){
Log.w(TAGBluetoothAdapter未初始化或指定的地址。);
} 最后BluetoothDevice类设备= mBluetoothAdapter.getRemoteDevice(地址);
INT connectState = mBluetoothManager.getConnectionState(设备,BluetoothProfile.GATT); mBluetoothGatt = device.connectGatt(这一点,真的,mGattCallback); } 公共无效断开(字符串地址){
// TODO自动生成方法存根
如果(mBluetoothAdapter == NULL){
Log.w(TAG,断开:BluetoothAdapter未初始化);
返回;
} 最后BluetoothDevice类设备= mBluetoothAdapter.getRemoteDevice(地址);
INT connectionState = mBluetoothManager.getConnectionState(设备,BluetoothProfile.GATT); 如果(mBluetoothGatt!= NULL){
Log.i(TAG,断开);
如果(connectionState!= BluetoothProfile.STATE_DISCONNECTED){
mBluetoothGatt.disconnect();
}其他{
Log.w(TAG,尝试在状态断开:+ connectionState);
}
}
}
@覆盖
公共无效的onDestroy(){
// TODO自动生成方法存根
super.onDestroy();
} //私人最终的IBinder粘结剂=新LocalBinder();
私人最终LocalBinder粘结剂=新LocalBinder();
公共类LocalBinder扩展粘结剂{
公共BluetoothLeService的getService(){
返回BluetoothLeService.this;
}
}
@覆盖
公众的IBinder onBind(意向意图){
// TODO自动生成方法存根
返回粘结剂;
} @覆盖
公共布尔onUnbind(意向意图){
// TODO自动生成方法存根
Log.i(TAGonUnbind);
关();
返回super.onUnbind(意向);
} 公共无效的close(){
// TODO自动生成方法存根
如果(mBluetoothGatt!= NULL){
mBluetoothGatt.close();
mBluetoothGatt = NULL;
}
}
}
我的解决方法的问题是推迟重新连接:
私人无效connectGatt(最后弦乐地址){
新的Timer()。时间表(新的TimerTask(){
@覆盖
公共无效的run(){
bluetoothGatt = bluetoothManager.getAdapter()getRemoteDevice(地址).connectGatt(背景下,真实,bluetoothGattCallback)。
}
},500);
}
I following the page Bluetooth Low Energy for developing in Android 4.3 for Bluetooth Low Energy .
I already can turn on the Bluetooth , scan the device and connect to the BLE device.
But it show the BluetoothGatt : android.os.DeadObjectException
after I try to connect to device(device.connectGatt)
and before discover the Service (mBluetoothGatt.discoverServices)
for the BLE device.
Before BluetoothGatt : android.os.DeadObjectException
it show the log like the following
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.
The full log when I connect to BLE device before discover Service is like the following
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): local rand(LSB ~ MSB) = 86 fe b8 98 d9 17 ec 85 11 5c 06 18 19 72 99 cf
W/bt-smp (10670): P1(LSB ~ MSB) = 00 00 01 04 00 05 10 07 07 02 03 00 01 10 07 07
W/bt-smp (10670): P1' = r XOR p1(LSB ~ MSB) = 86 fe b9 9c d9 12 fc 82 16 5e 05 18 18 62 9e c8
W/bt-smp (10670): Key(LSB ~ MSB) = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Plain text(LSB ~ MSB) = 86 fe b9 9c d9 12 fc 82 16 5e 05 18 18 62 9e c8
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = 09 51 07 24 65 d0 6d a0 b2 63 57 aa 60 28 29 ba
W/bt-smp (10670): C1(LSB ~ MSB) = 09 51 07 24 65 d0 6d a0 b2 63 57 aa 60 28 29 ba
W/bt-smp (10670): p2(LSB ~ MSB) = b4 6c 00 20 73 20 c5 93 40 62 51 d0 00 00 00 00
W/bt-smp (10670): p2' = C1 xor p2(LSB ~ MSB) = bd 3d 07 04 16 f0 a8 33 f2 01 06 7a 60 28 29 ba
W/bt-smp (10670): Key(LSB ~ MSB) = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Plain text(LSB ~ MSB) = bd 3d 07 04 16 f0 a8 33 f2 01 06 7a 60 28 29 ba
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = 20 4b 2b ab 92 cb 79 81 68 de 9e 62 d5 ac 4c 7b
W/bt-smp (10670): Confirm(LSB ~ MSB) = 20 4b 2b ab 92 cb 79 81 68 de 9e 62 d5 ac 4c 7b
D/BluetoothMasService( 8128): device: HelloFH
W/bt-smp (10670): peer rand(LSB ~ MSB) = 41 8d 98 57 20 2d 8f 51 18 93 4e cf 48 39 ac cf
W/bt-smp (10670): P1(LSB ~ MSB) = 00 00 01 04 00 05 10 07 07 02 03 00 01 10 07 07
W/bt-smp (10670): P1' = r XOR p1(LSB ~ MSB) = 41 8d 99 53 20 28 9f 56 1f 91 4d cf 49 29 ab c8
W/bt-smp (10670): Key(LSB ~ MSB) = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Plain text(LSB ~ MSB) = 41 8d 99 53 20 28 9f 56 1f 91 4d cf 49 29 ab c8
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = b2 4c b9 c1 65 2b ec 8f 86 74 82 4b d3 ca c6 9f
W/bt-smp (10670): C1(LSB ~ MSB) = b2 4c b9 c1 65 2b ec 8f 86 74 82 4b d3 ca c6 9f
W/bt-smp (10670): p2(LSB ~ MSB) = b4 6c 00 20 73 20 c5 93 40 62 51 d0 00 00 00 00
W/bt-smp (10670): p2' = C1 xor p2(LSB ~ MSB) = 06 20 b9 e1 16 0b 29 1c c6 16 d3 9b d3 ca c6 9f
W/bt-smp (10670): Key(LSB ~ MSB) = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Plain text(LSB ~ MSB) = 06 20 b9 e1 16 0b 29 1c c6 16 d3 9b d3 ca c6 9f
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = 04 9a 63 ea a0 fb 6d 9e 91 70 65 6d 54 26 d0 e1
W/bt-smp (10670): Compare(LSB ~ MSB) = 04 9a 63 ea a0 fb 6d 9e 91 70 65 6d 54 26 d0 e1
W/bt-smp (10670): Key(LSB ~ MSB) = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Plain text(LSB ~ MSB) = 86 fe b8 98 d9 17 ec 85 41 8d 98 57 20 2d 8f 51
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = 4a 97 52 da 4f ac 7e 4b 48 f1 ba 33 0d df 6f 72
E/bt-smp (10670): STK Generated
W/bt-smp (10670): Key(LSB ~ MSB) = 5e b8 49 86 94 c9 24 d3 79 10 96 8d f0 fa d6 df
W/bt-smp (10670): Plain text(LSB ~ MSB) = c9 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = dc 0b 54 34 a5 ff f1 6d 69 91 af f4 77 dd 44 09
W/bt-smp (10670): Key(LSB ~ MSB) = 67 e6 91 62 7a 0d 29 34 59 17 92 d8 8d 9b fa 89
W/bt-smp (10670): Plain text(LSB ~ MSB) = d6 ec 85 b8 8c 5f 22 32 00 00 00 00 00 00 00 00
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = cd 25 9e e0 c7 c3 c2 fe 1a 7e 2c 58 01 fa 97 17
E/bt-smp (10670): LTK ready
W/bt-smp (10670): smp_send_enc_info
W/bt-smp (10670): smp_send_id_info
W/bt-smp (10670): Key(LSB ~ MSB) = 5e b8 49 86 94 c9 24 d3 79 10 96 8d f0 fa d6 df
W/bt-smp (10670): Plain text(LSB ~ MSB) = c9 51 01 00 00 00 00 00 00 00 00 00 00 00 00 00
W/bt-smp (10670): Encrypted text(LSB ~ MSB) = 56 68 2a c9 e3 c8 b8 b8 97 5c fd e8 60 93 76 66
D/Diag_Lib( 507): [IMS_DEBUG]| 1035 | 535 |qpNetSelect : Select Unblocked , iRtn 0, errno 0, errno [Success]
E/Diag_Lib( 507): [IMS_FATAL]| 251 | 535 |qvp_rtp_handle_signals iRet : 0
E/Diag_Lib( 507): [IMS_FATAL]| 238 | 535 |qvp_rtp_handle_signals qpDplMainLoop: Calling imsSignalHandler
D/Diag_Lib( 507): [IMS_DEBUG]| 144 | 535 |qpDpl:imsSignalHandler
E/Diag_Lib( 507): [IMS_FATAL]| 155 | 535 |qpdpl:imsSignalHandler: GLobal data NULL or Event list size is 0
E/Diag_Lib( 507): [IMS_FATAL]| 243 | 535 |qvp_rtp_handle_signals add read fd : 8
E/bt-btif (10670): No More Service found
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 7
D/BtGatt.GattService(10670): onSearchResult() - address=20:73:20:00:6C:B4, uuid=00001801-0000-1000-8000-00805f9b34fb
D/BluetoothGatt( 8804): onGetService() - Device=20:73:20:00:6C:B4 UUID=00001801-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 7
D/BtGatt.GattService(10670): onSearchResult() - address=20:73:20:00:6C:B4, uuid=00001800-0000-1000-8000-00805f9b34fb
D/BluetoothGatt( 8804): onGetService() - Device=20:73:20:00:6C:B4 UUID=00001800-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 7
D/BtGatt.GattService(10670): onSearchResult() - address=20:73:20:00:6C:B4, uuid=1b7e8251-2877-41c3-b46e-cf057c562023
D/BluetoothGatt( 8804): onGetService() - Device=20:73:20:00:6C:B4 UUID=1b7e8251-2877-41c3-b46e-cf057c562023
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 7
D/BtGatt.GattService(10670): onSearchResult() - address=20:73:20:00:6C:B4, uuid=0000180a-0000-1000-8000-00805f9b34fb
D/BluetoothGatt( 8804): onGetService() - Device=20:73:20:00:6C:B4 UUID=0000180a-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 7
D/BtGatt.GattService(10670): onSearchResult() - address=20:73:20:00:6C:B4, uuid=0000180f-0000-1000-8000-00805f9b34fb
D/BluetoothGatt( 8804): onGetService() - Device=20:73:20:00:6C:B4 UUID=0000180f-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_upstreams_evt: Event 6
D/BtGatt.GattService(10670): onSearchCompleted() - connId=5, status=0
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1007
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=133, charUuid=5e0dae24-5e0d-adf0-409b-a23f420d6580, prop=94
D/BtGatt.btif(10670): btif_gattc_get_included_service
D/BtGatt.btif(10670): btgattc_handle_event: Event 1011
E/BtGatt.btif(10670): bta_to_btif_uuid: Unknown UUID length 24028!
D/BtGatt.GattService(10670): onGetIncludedService() - address=20:73:20:00:6C:B4, status=133, uuid=00001801-0000-1000-8000-00805f9b34fb, inclUuid=5e0dae24-5e0d-adf0-409b-a23f420d6580
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1007
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a00-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a00-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a01-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a01-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=133, charUuid=00002a01-0000-1000-8000-00805f9b34fb, prop=2
D/BtGatt.btif(10670): btif_gattc_get_included_service
I/bt-hci (10670): BLE HCI(id=62) event = 0x03)
I/bt-hci (10670): btu_ble_ll_conn_param_upd_evt
D/BtGatt.btif(10670): btgattc_handle_event: Event 1011
D/BtGatt.GattService(10670): onGetIncludedService() - address=20:73:20:00:6C:B4, status=133, uuid=00001800-0000-1000-8000-00805f9b34fb, inclUuid=00002a01-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1007
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=8ac32d3f-5cb9-4d44-bec2-ee689169f626, prop=50
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=8ac32d3f-5cb9-4d44-bec2-ee689169f626
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=5e9bf2a8-f93f-4481-a67e-3b2f4a07891a, prop=10
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=5e9bf2a8-f93f-4481-a67e-3b2f4a07891a
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=d5b8304c-076a-42ce-9d1e-1c859336363f, prop=50
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=d5b8304c-076a-42ce-9d1e-1c859336363f
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=f4bfe056-701d-4af7-a326-d2ecd00173f4, prop=10
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=f4bfe056-701d-4af7-a326-d2ecd00173f4
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=b1736a91-c910-4ad2-ab3a-fd72cc55903d, prop=10
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=b1736a91-c910-4ad2-ab3a-fd72cc55903d
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=ff890e61-5600-4426-88cf-090abe01d0b8, prop=10
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=ff890e61-5600-4426-88cf-090abe01d0b8
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=74de75ce-03b7-4e62-84d0-0d229d456836, prop=10
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=74de75ce-03b7-4e62-84d0-0d229d456836
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=133, charUuid=74de75ce-03b7-4e62-84d0-0d229d456836, prop=10
D/BtGatt.btif(10670): btif_gattc_get_included_service
D/BtGatt.btif(10670): btgattc_handle_event: Event 1011
D/BtGatt.GattService(10670): onGetIncludedService() - address=20:73:20:00:6C:B4, status=133, uuid=1b7e8251-2877-41c3-b46e-cf057c562023, inclUuid=74de75ce-03b7-4e62-84d0-0d229d456836
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1007
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a29-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a29-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a24-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a24-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a23-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a23-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=133, charUuid=00002a23-0000-1000-8000-00805f9b34fb, prop=2
D/BtGatt.btif(10670): btif_gattc_get_included_service
D/BtGatt.btif(10670): btgattc_handle_event: Event 1011
D/BtGatt.GattService(10670): onGetIncludedService() - address=20:73:20:00:6C:B4, status=133, uuid=0000180a-0000-1000-8000-00805f9b34fb, inclUuid=00002a23-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1007
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=0, charUuid=00002a19-0000-1000-8000-00805f9b34fb, prop=2
D/BluetoothGatt( 8804): onGetCharacteristic() - Device=20:73:20:00:6C:B4 UUID=00002a19-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_characteristic
D/BtGatt.btif(10670): btgattc_handle_event: Event 1008
D/BtGatt.GattService(10670): onGetCharacteristic() - address=20:73:20:00:6C:B4, status=133, charUuid=00002a19-0000-1000-8000-00805f9b34fb, prop=2
D/BtGatt.btif(10670): btif_gattc_get_included_service
D/BtGatt.btif(10670): btgattc_handle_event: Event 1011
D/BtGatt.GattService(10670): onGetIncludedService() - address=20:73:20:00:6C:B4, status=133, uuid=0000180f-0000-1000-8000-00805f9b34fb, inclUuid=00002a19-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_descriptor
D/BtGatt.btif(10670): btgattc_handle_event: Event 1009
D/BtGatt.GattService(10670): onGetDescriptor() - address=20:73:20:00:6C:B4, status=133, descUuid=00002a19-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_descriptor
D/BtGatt.btif(10670): btgattc_handle_event: Event 1009
D/BtGatt.GattService(10670): onGetDescriptor() - address=20:73:20:00:6C:B4, status=133, descUuid=00002a19-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_descriptor
D/BtGatt.btif(10670): btgattc_handle_event: Event 1009
D/BtGatt.GattService(10670): onGetDescriptor() - address=20:73:20:00:6C:B4, status=0, descUuid=00002902-0000-1000-8000-00805f9b34fb
D/BluetoothGatt( 8804): onGetDescriptor() - Device=20:73:20:00:6C:B4 UUID=00002902-0000-1000-8000-00805f9b34fb
D/BtGatt.btif(10670): btif_gattc_get_descriptor
D/BtGatt.btif(10670): btgattc_handle_event: Event 1010
I am not sure why the E/BluetoothGatt( 8804): android.os.DeadObjectException
happened.
After this error happened , I can not discover the service for BLE device when I run mBluetoothGatt.discoverServices
.
I have to disconnect and re-connect to BLE device again. And it work fine.
If I clean the data for Bluetooth in Android setting and connect to the BLE device again. The error happened again...
And Sometime it will disconnect immediately after connect , so I have to connect again.
Does somebody has same error or condition ? Please help me or teach me how to solve this problem , it confused a few day...
Thanks in advance! --------------------------------------------------EDIT-----------------------------------------------
The code of the Service is like the following:
package com.ampak.pace;
public class BluetoothLeService extends Service{
static final String TAG = "BluetoothLeService";
private static BluetoothAdapter mBluetoothAdapter = null;
private static BluetoothManager mBluetoothManager = null;
private BluetoothGatt mBluetoothGatt = null;
private String mBluetoothDeviceAddress;
private BluetoothDevice device;
public static String address = null;
public static Handler handler=new Handler(Looper.getMainLooper());
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
public void onConnectionStateChange(android.bluetooth.BluetoothGatt gatt, int status, int newState) {
if(mBluetoothGatt == null){
Log.e(TAG, "mBluetoothGatt not created!");
return;
}
device = gatt.getDevice();
address = device.getAddress();
try {
switch (newState) {
case BluetoothAdapter.STATE_CONNECTED:
Log.i(TAG, "STATE_CONNECTED:");
broadcastUpdate(ACTION_GATT_CONNECTED, device, status);
break;
case BluetoothAdapter.STATE_DISCONNECTED:
Log.i(TAG, "STATE_DISCONNECTED:");
gatt.close();
broadcastUpdate(ACTION_GATT_DISCONNECTED, device, status);
break;
default:
Log.i(TAG, "New state not processed: " + newState);
break;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if(status == BluetoothGatt.GATT_SUCCESS) {
}
};
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if(status == BluetoothGatt.GATT_SUCCESS){
Log.i(TAG, "onServicesDiscovered-----GATT_SUCCESS@@@@@@ = ");
}
};
};
private void broadcastUpdate(final String action, final BluetoothDevice device , final int status) {
// TODO Auto-generated method stub
final Intent intent = new Intent(action);
intent.putExtra(EXTRA_UUID, device);
intent.putExtra(EXTRA_STATUS, status);
sendBroadcast(intent);
}
public boolean initialize() {
// TODO Auto-generated method stub
if(mBluetoothManager == null){
Log.e(TAG, "BluetoothManager initialize@@@");
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
if(mBluetoothManager == null){
Log.e(TAG, "Unable to initialize BluetoothManager");
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
if(mBluetoothAdapter == null){
Log.e(TAG, "Unable to obtain a BluetoothAdapter");
return false;
}
return true;
}
public void connect(final String address) {
// TODO Auto-generated method stub
Log.w(TAG, "BluetoothLeService Connect function.");
if(mBluetoothAdapter == null || address == null){
Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
int connectState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT);
mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
}
public void disconnect(String address) {
// TODO Auto-generated method stub
if(mBluetoothAdapter == null){
Log.w(TAG, "disconnect: BluetoothAdapter not initialized");
return;
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
int connectionState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT);
if(mBluetoothGatt != null){
Log.i(TAG, "disconnect");
if(connectionState != BluetoothProfile.STATE_DISCONNECTED){
mBluetoothGatt.disconnect();
}else{
Log.w(TAG, "Attempt to disconnect in state: " + connectionState);
}
}
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
//private final IBinder binder = new LocalBinder();
private final LocalBinder binder = new LocalBinder();
public class LocalBinder extends Binder{
public BluetoothLeService getService() {
return BluetoothLeService.this;
}
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return binder;
}
@Override
public boolean onUnbind(Intent intent) {
// TODO Auto-generated method stub
Log.i(TAG, "onUnbind");
close();
return super.onUnbind(intent);
}
public void close() {
// TODO Auto-generated method stub
if (mBluetoothGatt != null) {
mBluetoothGatt.close();
mBluetoothGatt = null;
}
}
}
My workaround to the problem was to delay the reconnection:
private void connectGatt(final String address) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
bluetoothGatt = bluetoothManager.getAdapter().getRemoteDevice(address).connectGatt(context, true, bluetoothGattCallback);
}
}, 500);
}
这篇关于如何解决BluetoothGatt:在Android中发生android.os.DeadObjectException错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!