0

In my android app, that collects data from BLE device and draws it to chart, I use a handler for various calls, one of them is to read RSSI values. The app runs fine, but after 40 minutes the data stop coming and the obviously the chart stops drawing, and I get the following exception over and over (every amount of time I set the handler to call the RSSI read:

I/HANDLER:: MSG_CHECK_RSSI
D/BluetoothGatt: readRssi() - device: 03:80:E1:55:34:XX
E/BluetoothGatt: android.os.DeadObjectException
                 at android.os.BinderProxy.transactNative(Native Method)
                 at android.os.BinderProxy.transact(Binder.java:628)
                 at android.bluetooth.IBluetoothGatt$Stub$Proxy.readRemoteRssi(IBluetoothGatt.java:1147)
                 at android.bluetooth.BluetoothGatt.readRemoteRssi(BluetoothGatt.java:1318)
                 at com.nanovation.senseguard_monitor.SensorPlotting.handleMessage(SensorPlotting.java:715)
                 at android.os.Handler.dispatchMessage(Handler.java:98)
                 at android.os.Looper.loop(Looper.java:154)
                 at android.os.HandlerThread.run(HandlerThread.java:61)
D/BluetoothAdapter: onBluetoothStateChange: up=true
                onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
D/BluetoothGatt: onBluetoothStateChange: up=true
             onBluetoothStateChange: Bluetooth is on
I/HANDLER:: MSG_CHECK_RSSI
D/BluetoothGatt: readRssi() - device: 03:80:E1:55:34:XX
E/BluetoothGatt: android.os.DeadObjectException
                 at android.os.BinderProxy.transactNative(Native Method)
                 at android.os.BinderProxy.transact(Binder.java:628)
                 at     android.bluetooth.IBluetoothGatt$Stub$Proxy.readRemoteRssi(IBluetoothGatt.java:1147)
                 at android.bluetooth.BluetoothGatt.readRemoteRssi(BluetoothGatt.java:1318)
                 at com.nanovation.senseguard_monitor.SensorPlotting.handleMessage(SensorPlotting.java:715)
                 at android.os.Handler.dispatchMessage(Handler.java:98)
                 at android.os.Looper.loop(Looper.java:154)
                 at android.os.HandlerThread.run(HandlerThread.java:61)

my code in the Handler:

         case MSG_CHECK_RSSI:
            logger.finer("MSG_CHECK_RSSI");
            Log.i(HANDLER_TAG, "MSG_CHECK_RSSI");

            if (mBluetoothGatt != null)
            {
                try
                {
                    mBluetoothGatt.readRemoteRssi();
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                    Log.i("read rssi", "mBluetoothGatt.readRemoteRssi() problem");
                }
            }

            checkRssi();
            break;

call method:

    private void checkRssi()
{
    //check rssi every X time
    bleHandler.sendEmptyMessageDelayed(MSG_CHECK_RSSI, 1000);
}

even though it's in a try catch block, the catch block never gets called. I tried print logs about the gatt status:

  • the state is the same as before: 12 which means "ON".
  • mBluetoothGatt is not null.
  • the scan mode is the same as before: 21 which means "connectable".
  • isDiscovering = false
  • the device connected is not null and has the same mac address.

The app is responsive and not stuck, just the data stop flowing and the rssi exception keep appearing (the app doesn't crush).

I don't know what else to check :(

************************** EDIT **************************** I tried set the rssi call to every 5 seconds (instead of 1), it didn't help. when I commented the rssi call the problem didn't occured (I need to test it longer), but I guess the problem is with the rssi call. Any suggestions?

Geeky bean
  • 475
  • 6
  • 21

0 Answers0