Unexpected Disconnect occurring frequently

I have included an onUnexpectedDisconnect with the board on my android application.
Under what circumstances does the function trigger?
I have been testing on multiple phones and some of them see a lot of triggers while others dont. Is there anything I can change in my code to handle the triggering of the function?

Comments

  • @Vinay said:
    I have included an onUnexpectedDisconnect with the board on my android application.
    Under what circumstances does the function trigger?

    It works exactly as the name says:
    https://mbientlab.com/androiddocs/latest/metawearboard.html#unexpected-disconnects

    I have been testing on multiple phones and some of them see a lot of triggers while others dont. Is there anything I can change in my code to handle the triggering of the function?

    What do you currently do in the handler?

  • edited April 2019

    I am getting frequent disconnects on certain devices and no disconnects on others

    What do you currently do in the handler?

    board = serviceBinder.getMetaWearBoard(remoteDevice);
    board.onUnexpectedDisconnect(new MetaWearBoard.UnexpectedDisconnectHandler() {
                @Override
                public void disconnected(int status) {
                    Log.v("UNEXPECTED", "Occured");
            // A few UI changes that I want whenever an Unexpected Disconnect is detected
                }
            });
    
  • edited April 2019

    You need to handle disconnects and automatically re-connect. This is typical of Bluetooth.
    A disconnect or a failed connection is very typical in Bluetooth and should always be handled with smart code.

    If the disconnect is happening every few seconds or more than twice, it could be a different issue. This would point to a Bluetooth issue on your machine or a problem with the sensor (the most likely suspect is battery).

Sign In or Register to comment.