- 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/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!