Connecting requires multiple retries

edited August 2016 in Android
Since upgrading the firmware to the latest version I have difficulties connecting to the board. Using the Cordova plugin I need to call the connect function multiple times (most calls fail with "ERROR"). Looking in the android log using logcat I see the following exception:

java.lang.RuntimeException: onConnectionStateChanged reported non-zero status: 133

After multiple tries it works. It also seems to affect the MetaWear app, connecting takes a long time (I guess the app tries the connect multiple times after errors?).

Is there something I'm missing/overlooking, or is something else wrong?


Note: I'm not sure if this is related to the firmware, that might just be a coincidence.


  • hmmm.  That does make me wonder if something has changed.  I'll take a look at it when I get a chance.  Wondering if something has changed that I might need to account for with the Cordova Plugin.
  • There has not been any changes to the BLE code in a long time.  Can you try connecting to the MetaWear using the nRF BLE app?  If you see the same behaviour there, then try turning off both wifi and BT then turn on only BT.
  • I can connect with both apps, as well as with the Cordova app, but sometimes I need to retry multiple times.

    I do keep getting the below exception, but only when using the Cordova plugin, what does it mean?

    java.lang.RuntimeException: onConnectionStateChanged reported non-zero status: 133

    at com.mbientlab.metawear.MetaWearBleService$2$

    at java.util.concurrent.Executors$


    at java.util.concurrent.ThreadPoolExecutor.runWorker(

    at: java.util.concurrent.ThreadPoolExecutor$


  • Ok,  looks like this is a issue with the Cordova app.
  • Hi, all,
    I have a similar connection problem (nothing to do with Cordova), but I've observed it on the earlier versions of FW/API.
    At some stage, when I'm trying to connect to device after using device (never after MW clear boot) it goes into infinite connection loop (see log below). If I Cancel connection attempt - device disappears from the list of available devices. Same connection loop is happening in MetaWear app.
    However, I can connect to the device from nRF app and see the services. 
    Could you suggest someting?

    08-12 08:49:50.396 8496-8496/ D/BluetoothGatt: connect() - device: D9:97:01:8C:2B:B9, auto: false
    08-12 08:49:50.396 8496-8496/ D/BluetoothGatt: registerApp()
    08-12 08:49:50.396 8496-8496/ D/BluetoothGatt: registerApp() - UUID=a24f47e9-a44e-4518-8c1f-61ee82abf981
    08-12 08:49:50.416 8496-8735/ D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7
    08-12 08:49:50.436 8496-8507/ D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=D9:97:01:8C:2B:B9
    08-12 08:49:50.436 8496-8507/ D/BluetoothGatt: refresh() - device: D9:97:01:8C:2B:B9
    08-12 08:49:50.436 8496-8507/ D/BluetoothGatt: close()
    08-12 08:49:50.436 8496-8507/ D/BluetoothGatt: unregisterApp() - mClientIf=7
    08-12 08:49:50.446 8496-8496/ D/BluetoothGatt: connect() - device: D9:97:01:8C:2B:B9, auto: false
  • It's possible the infinite loop is caused by the automatic reconnect.  You can break the infinite connect by turning off the bt adapater.
  • This typically happens when device has lost the connection due do distance or physical obstacles and I'm trying to manually connect to it again (even after app restart or switching to Metawear app). Since I have buzzer beep on fromDisconnect monitor I can hear that device regularly disconnects in the process.

    Disconnecting Bluetooth does not help, only device restart by disconnecting battery helps, which is not the most user-friendly solution.
  • What Android device and OS are you using?  This sounds similar to an issue some users encountered resulting from killing an app before closing the BT connection.
  • Samsung S5 with Android 5.0

    I've actually solved it by introducing watchdog, which reboots module if no bluetooth transactions are performed for longer than N seconds or module disconnected. After this I can connect to fresh device.
    I think the initial problem is also correlated with amount of data transferred. I have an impression that device goes into this "unreachable" state when connection was lost during intensive streaming.

  • @propan ;
    What is a "watchdog"?
  • Generally speaking, a watchdog is a piece of code (or hardware) that monitors the system for specific issues.
This discussion has been closed.