- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我关注 Bluetooth Low Energy 页面以在 Android 4.3 中为 Bluetooth Low Energy 开发。
我已经可以打开蓝牙,扫描设备并连接到 BLE 设备。
但它显示 BluetoothGatt : android.os.DeadObjectException
在我尝试连接到设备(device.connectGatt)
和 在发现 BLE 设备的服务之前 (mBluetoothGatt.discoverServices)
。
在 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): 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
我不确定为什么会发生 E/BluetoothGatt( 8804): android.os.DeadObjectException
。发生此错误后,当我运行 mBluetoothGatt.discoverServices
时无法发现 BLE 设备的服务。
我必须再次断开并重新连接到 BLE 设备。而且效果很好。
如果我在 Android 设置中清除蓝牙数据并再次连接到 BLE 设备。错误又发生了...
有时连接后会立即断开连接,所以我必须重新连接。
有人有同样的错误或情况吗?请帮助我或教我如何解决这个问题,它困惑了几天......
提前致谢!-------------------------------------------- - -编辑 - - - - - - - - - - - - - - - - - - - - - - - -
Service的代码如下:
包 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;
}
}
}
最佳答案
我通过断开连接、关闭 Gatt 并停止服务然后重新启动来解决此问题:
mBluetoothLeService.disconnect();
mBluetoothLeService.close();
mBluetoothLeService.stopSelf();
connectBleservice();
关于android - 如何解决Android中发生的BluetoothGatt : android. os.DeadObjectException错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23947874/
我正在开发一个需要与蓝牙 LE 设备通信的应用程序。 这是我用来设置 CharacteristicNotification 的代码 public boolean setCharacteristicNo
我正在构建一个应用程序来从蓝牙设备读取数据。连接到设备后,我调用 mBluetoothGatt.discoverServices()在onServicesDiscovered(..)我正在通过调用 g
我正在尝试连接到外围设备。当我在 Scancallback 中找到所需的设备时,我会向我的处理程序发送一条包含该设备的消息。 11-16 10:31:12.471 25907-25907/I/BleM
从文档中我看到如何在没有响应的情况下这样写: BluetoothGattCharacteristic characteristic = ... characteristic.setValue(byte
我一直无法通过同一个蓝牙 LE 设备同时使用两个不同的特性。它只记录第一个特征而不记录第二个特征。如果我调换它们,它仍然会记录第一个,但不会记录第二个。第一和第二特征都需要注册和接收。如果有帮助,我正
当扩展 BluetoothGattCallback 时,实现者应该调用 super 方法吗? 例子: public void onCharacteristicWrite(BluetoothGatt g
实际上我是通过蓝牙进行更新的。第一次我删除存储体,然后在上面写入一个十六进制文件。 但是有一半的时间更新无法正常工作,对于我传输的每个数据,第一个 writeCharacteristic 将返回 fa
我创建了一个具有 WRITE_TYPE_NO_RESPONSE 特性的外设。对于另一个应用程序,我写了特性,但我偶尔会遇到带有 lollipop 5.1.1 的 samsung galaxy nexu
我的应用程序与 BLE 外围设备通信。有时,应用程序会在已连接外围设备的情况下启动。我可以通过调用以下方式取回设备: BluetoothManager manager = (BluetoothMana
我正在编写一个 Android 应用程序以使用 BLE 与 Arduino 对话。我已经能够扫描设备,连接到目标,发现服务,获取特征,并读取那些可读的。但是,当我尝试编写可写特性时,该方法总是返回 f
首先我阅读了SOLVED: GATT callback fails to register并采取了该帖子中建议的步骤来解决此问题,但没有成功。如果您还没有阅读,建议的修复方法是直接从主线程或使用处理程
我遇到了一个让我完全困惑的问题,主要是因为它的顽固性。 我正在编写一个小型 Android 应用程序来与我的 Bluegiga BLE113 进行通信。我以前连接过这个设备,但我最近做了一个 GATT
我正在连接到蓝牙 LE 外围设备作为中心。我正在将数据写入特征,并通过通知以 20 字节为单位接收数据。 通知订阅: private void setCharacteristicNotificatio
我正在尝试编写 BLE Android 应用程序。我发现有时当我打电话 BluetoothGatt.writeDescriptor()它返回 false。 我没有在文档中找到任何对此功能的限制说明。但
Android BluetoothGatt.class 有 mClientIf 私有(private)字段。大多数与 BLE 事件相关的日志消息都包含此值。例如: onClientRegistered
我正在尝试写入 BLE 设备的特性。根据文档,这个特性是可以读和写的,有不同的用法。我已经成功地读取了它,但是我在写入时遇到了一些问题。每次我尝试写入它时,onWriteCharacterstic 函
我有一个从 IntentService 调用的 BluetoothLeService。 BLEService 在连接之前工作正常。与 iBeacon 建立连接后,调用 ; public void on
我们正在编写一个 ble 应用程序,它希望与我们要连接的外围设备建立持久连接。出于同样的目的,我们希望在失去现有连接时重新连接外围设备。因此,作为中心的 android 应用程序只是尝试使用 blue
我正在编写一个 Android 应用程序来与 BLE 仪表通信。我已经能够扫描设备、连接到目标、发现服务、获取特征。然而,当我尝试编写 write_no_reponse 特性时,该方法总是返回 fal
我正试图在退出我的应用程序时断开特征通知。以下是我在 exitCleanup() 函数中的做法: if (btGatt != null && mWriteChar != null) { bool
我是一名优秀的程序员,十分优秀!