Anonymous Routes

I have been trying to create an anonymous route for the step counter.  I have tried running the example code here but get the following error when trying to obtain the identifier:  "java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String com.mbientlab.metawear.Route.generateIdentifier(int)' on a null object reference".  'task.getResult()' returns 'null'.  I have also tried running variations of the code almost identical to the reference with other sensors with the same result.  Is the code still valid? TIA for the guidance.

Comments

  • Post your code.
  • edited December 2017
    A link to the relevant code snippet is here. Note that my initial test was simply to use the code below in my setFixedRoute class.

    (where private MetaWearBoard board;)
    // create a route to log gyro y-axis data
    this.board.getModule(GyroBmi160.class).angularVelocity().addRouteAsync(new RouteBuilder() {
    @Override
    public void configure(RouteComponent source) {
    source.split().index(1).log(null);
    }
    }).continueWith(new Continuation() {
    @Override
    public Void then(Task task) throws Exception {
    // save the result of generateIdentifier and hardcode
    // value in anonymous route
    Log.i("MainActivity", "subscriber (0) = " + task.getResult().generateIdentifier(0));
    return null;
    }
    });
  • edited December 2017
    The task's result should not be null in this context, which indicates the task failed.  Confirm that the task did fail and post its error.
  • edited December 2017
    Have a look at my code where I did include the error handling.  That's how I obtained the error statement I cited above ... and naturally now that I posted, I can't reproduce the error consistently.  What shows up: ' java.util.concurrent.TimeoutException: Creating logger timed out "  Why might the logger time out sporadically?

    When it works I get the error: " D/Activity: IllState: java.lang.IllegalStateException: Cannot create uri for data type: [0x03, 0xda, 0xff]. "  which means the route's being created but I only expected one byte.  The angular velocity example uses "source.split().index(1).log(null).  I understand what is being done but I don't understand why.  It looks like a route is being created for angular velocity 'y' axis.  In the case of step counter what would that process be doing?
  • Follow the example code provided in the Bolts documentation:
    https://github.com/BoltsFramework/Bolts-Android#error-handling
  • Logger timeouts typically occur when the user tries to allocate too many loggers or continues to add loggers without removing old loggers.

    The illegal state exception with the step counter identifier is a bug with the Android SDK that will be patched up shortly.
  • SDK v3.3.0 has been released which fixes using anonymous routes with the step counter.
  • Woot!  Tnx for quick turnaround!!!
This discussion has been closed.