2

I am using Android ble to develop an application. The app will connect with the external device using ble. The external device has a sensor that records data and as soon as the android device comes in range, data transmission begins. The android app will register to be notified if a particular characteristic changes and when both devices are connected, data is transmitted through

setCharacteristicNoification() --> onCharactericticChanged()

Now this works fine for data collected by sensor under 5-10 minutes. But if the devices are out of range for say more than 15 minutes and all this data now has to be transferred, the app exits on itself.

On reading about this on several forums, I checked the system logs and found this error:

BluetoothServiceJni: An exception was thrown by callback 'btgattc_notify_cb'. 
BluetoothServiceJni: android.os.DeadObjectException
                                                      at android.os.BinderProxy.transactNative(Native Method)
                                                      at android.os.BinderProxy.transact(Binder.java:496)
                                                      at android.bluetooth.IBluetoothGattCallback$Stub$Proxy.onNotify(IBluetoothGattCallback.java:840)
                                                      at com.android.bluetooth.gatt.GattService.onNotify(GattService.java:838)

After this exception message was repeated several times I get this message

BtGatt.AdvertiseManager: stop advertise for client 5
 BtGatt.GattService: onAdvertiseInstanceDisabled() - clientIf=5, status=0
 BtGatt.GattService: Client app is not null!
 BtGatt.AdvertiseManager: failed onAdvertiseInstanceDisabled
 android.os.DeadObjectException at 
 android.os.BinderProxy.transactNative(Native Method) at 
 android.os.BinderProxy.transact(Binder.java:496) at android.bluetooth.IBluetoothGattCallback$Stub$Proxy.onMultiAdvertiseCallback(IBluetoothGattCallback.java:874)at com.android.bluetooth.gatt.GattService.onAdvertiseInstanceDisabled(GattService.java:1242) at com.android.bluetooth.gatt.AdvertiseManager$AdvertiseNative.stopAdvertising(AdvertiseManager.java:318)at com.android.bluetooth.gatt.AdvertiseManager$ClientHandler.handleStopAdvertising(AdvertiseManager.java:212) at com.android.bluetooth.gatt.AdvertiseManager$ClientHandler.handleMessage(AdvertiseManager.java:175) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.os.HandlerThread.run(HandlerThread.java:61)

BtGatt.AdvertiseManager: app died - unregistering client : 5

And finally this message:

BtGatt.ContextMap: Context not found for ID 5

I am not sure what the problem with my code is and what part of code is causing this. Can anyone shed some light on what this issue might be?

Saurabh
  • 434
  • 1
  • 4
  • 19

1 Answers1

3

After reading through several forums and StackOverflow posts, I came to conclusion that there was nothing wrong with my code that could cause this crash.

The background bluetooth service was unable to handle the amount of data that was being transferred. Since we have our custom hardware, we were able to get it working by reducing the frequency of notifications.

Earlier we were sending 6 notifications( = 96 bytes) in 7.5 ms(minimum connection interval for android). By increasing the time interval to 10ms, we were able to stabilise the app.

If anybody is facing a similar issue, you may want to reduce the frequency of data transfer because background service cannot handle that type of throughput.

Saurabh
  • 434
  • 1
  • 4
  • 19