MetawearRG reconnection/connection TimeOut Issue

Hi, 

I m using MetawearRG for live data streaming. I am configuring Accelerometer and Gyrometer in range of 16G and 2000 deg/sec respectively, and using packedAcceleration and and PackedAngularVelocity for high data streaming. And using both at the same time.

I am disconnecting the board using board.disconnectAsync() function.

I am facing the problem when I try to reconnect the board after disconnecting it manually.

Issue: On selecting the board from the scanned list it stays on connecting state, and never complete.


On thorough debugging I found that, when ever the connection fail it goes for reconnection automatically, and the same procedure is carried on and on which lead to a infinite loop.

On further debugging I found that the value of task.isFaulted() in connectAsync() s always true whenever this condition arises, and the reason is that it throws an unhandled TimeOut Exception

everytime for this condition.


If I kill the app and try connecting again, it connect without ant hassle in 1st attempt, and the problem start occurring from 2nd attempt to connect


Please Help me out on handling this TimeOut Exception


                    


Comments

  • What is log output displayed in Logcat during the connection attempts?  Is the board at least able to connect with the Android device?

    Are you stopping the streams before disconnecting?

  • 1.Here is the Logcat when Scanning for devices.  

    2.Here is the logcat while connecting the board with android devices for successful attempt.

    3.Here is the logcat when disconnecting manually

    4.Here is the logcat  for unsuccessful Connection attempt. 


    board is connecting with android device only for the first time, and after dissconnecting it its not able to connect with device.

    Logcat #4 (unsuccessful Connection attempt) keeps on appearing again and again without giving any error message. 


    Yes, I am always stopping accelerometer and gyro meter before disconnecting the board , since I am using PackedAcceleration and PackedAngularVelocity, I am using these lines for stopping acclero and gyro meter 

    accelerometer.stop();

    gyro.stop();
    accelerometer.packedAcceleration().stop();
    gyro.packedAngularVelocity().stop();
    accelerometer.acceleration().stop();
    gyro.angularVelocity().stop();
    board.tearDown();


    after these function I am using board.disconnectAsync() to disconnect

     

  • edited October 2017
    Hi, 
    I am using the disconnect function in two places:
    1. In Menu option, where only the board get disconnected , and app remain active.
    2. Disconnection board just before closing the app.

    I noticed that the above problem only occur when #1 method is used. If I close the (#2 method) and restart then its work perfectly fine,   

    Code Snippet for Condition #1:

        if (mwBoard.isConnected()) {
        mwBoard.disconnectAsync().continueWith(new Continuation<Void, Void>() {
            @Override
    public Void then(Task<Void> task) throws Exception {
    Log.i("Activity", "Device Disconnected");

    return null;
    }
    });
    }

    Code Snippet for Condition #2:
        if(mwBoard.isConnected()) {
    mwBoard.disconnectAsync().continueWith(new Continuation<Void, Void>() {
    @Override
    public Void then(Task<Void> task) throws Exception {
    Log.i("Activity", "Device Disconnected");
    return null;
    }
    });
        }
        super.onBackPressed();

    For Condition #2 app work perfectly fine, Problem arises only for Condition #1
  • Hrm, so looking at the log output, the board does connect but it fails at the service discovery portion.  
    Try creating a blank app that only has a "connect" and "disconnect' button and see if your Android device can repeatedly connect/disconnect without and issues to your RG board.
This discussion has been closed.