Disconnect from board side automatically after certain time

edited February 2016 in Android
I tried to add a function so that the board disconnects after inactivity a certain time. Didn't find any good API calls but tried to add a disconnect every minute with a timer. However, doesn't really look like it works or am I doing something wrong/better way to do it?

final Debug debugModule = mwBoard.getModule(Debug.class);
            AsyncOperation<com.mbientlab.metawear.module.Timer.Controller> taskResult= mwBoard.getModule(com.mbientlab.metawear.module.Timer.class)
                    .scheduleTask(new com.mbientlab.metawear.module.Timer.Task() {
                        public void commands() {
                    }, 60 * 1000, true);
            taskResult.onComplete(new AsyncOperation.CompletionHandler<com.mbientlab.metawear.module.Timer.Controller>() {
                public void success(com.mbientlab.metawear.module.Timer.Controller result) {
                    // start executing the task


  • Nothing looks wrong with your code. Having the board trigger the disconnect may execute the failure function if it sends a nonzero status to the gatt callback.
This discussion has been closed.