Anonymous Route issues (not creating and downloading correctly)

edited November 2020 in Android

I'm working on an application with multiple metawear sensors, simultaneous logging then one-at-a-time downloading in a separate app. I had been using anonymous routes, but I have dropped some sessions, apparently because the anonymous routes did not properly receive logged data.

Board information

  • MMR sensors
  • Hardware 0.4
  • Firmware 1.5.0
  • Model number 5

Host Device Information

  • Samsung Galaxy A10e
  • Android 9 (security patch February 1, 2020) and Android 10 (security patch October 1, 2020)

Description

I worked off the tutorials and documentation to set up my routes as follows:

//////////////////// in setup function ///////////////////////////////
if (!routesCreated) {
    Semaphore sem = new Semaphore(1);
    try {
        sem.acquire();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    for (int i = 0; i < numBoardsConnected; i++) {
        mwBoard = myBoardList.get(i);
        mwBoard.createAnonymousRoutesAsync().onSuccess(new AnonRouteContinuation(
            i, sem, outputStreams[0].get(i), outputStreams[1].get(i), 
        outputStreams[2].get(i), outputStreams[3].get(i)));
        try {
            sem.acquire();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    routesCreated = true;
}

//////////////////////////////////////////////////////////////

private class AnonRouteContinuation implements Continuation{

    private FileOutputStream myFOS_accel, myFOS_gyro, myFOS_mag, myFOS_def;
    private int index;
    private Semaphore sem;

    public AnonRouteContinuation(int ind,Semaphore s, FileOutputStream fos_a, FileOutputStream fos_g, FileOutputStream fos_m, FileOutputStream fos_def){
        super();
        index = ind;
        sem = s;
        myFOS_accel = fos_a;
        myFOS_gyro = fos_g;
        myFOS_mag = fos_m;
        myFOS_def = fos_def;
    }

    @Override
    public Object then(Task task) throws Exception {
        for (final AnonymousRoute it : ((Task<AnonymousRoute[]>) task).getResult()) {
            it.subscribe(new ARKSubscriber_anon(index, myFOS_accel, myFOS_gyro, myFOS_mag,myFOS_def, it.identifier() ));
            Log.i(LOG_TAG, "Anon Route Identifier: " + it.identifier());
        }
        sem.release();
        return null;
    }
}

following from https://mbientlab.com/androiddocs/latest/advanced_features.html#anonymous-routes

SDK

  • Windows 10/Android Studio 4.0.1
  • SDK version 3.7.1

Collection side- I am logging three sensors (accelerometer at 100hz, gyroscope at 100hz, magnetometer at 10hz) to a set of metawear boards. The collection app initializes by tearing down the boards and configuring the sensors. It then starts logging, the sensors, and their producers for a couple minutes, stops everything for roughly a half hour, and repeats. At the end of a multi-hour session, each board should have logged data created by the three producers for each interval. All operations are run across all sensors, and most board operations are conducted one at a time using semaphores to avoid connection issues.

Download side - based on the above code, the phone should establish anonymous routes for each route (accel, gyro and mag) stored on the board. I am then downloading using downloadAsync(), all in a foreground service.

Expected behavior: For anonymous route creation, I should see an anonymous route for each of the original routes, as documented by the log statement in the above continuation. For download, I should expect to see the same amount of data (roughly) on each sensor, as confirmed by the downloadUpdateHandler. I should also find all data saved to disk, sorted into the filestreams based on the identifier it comes with.

Observed behavior: I am seeing the correct amount of data download (according to updateHandler), but for a subset of the sensors, files are missing some or all data, indicating the subscriber did not capture all the data. I have run into the bug three times, but I did not get the logs of the first bug. For the second case, no routes were created according to logs, and no data was transferred to files. From the third case, I lost one sensor's data - similarly I saw print outs from the identifier log statement, but not for the board that dropped the data. This indicates that the setup for the routes is failing, so my continuation is never called, or no routes are returned by the task. When downloadAsync gets called, however, the correct amount of data gets downloaded for all sensors (according to the updateHandler). Since I don't have a subscriber for the problem board, I can't access it or save it.

I would include more information on how to reproduce this if I had it- that's one of my issues, I can't tell what is causing the routes to not create.

Set of questions:

I've been experiencing range and noise issues in the data collection environment - is it possible that starting a running producer again could corrupt an existing route? or that some communication on the collection side could corrupt routes?
Is there a way to handle failures of anonymous route creations gracefully, so that I can still get the data that's on the board?
If not, since this is all on the same device - should I use board state serialization to save to the phone, then load and check for routes at time of download and assign explicit subscribers then?

Thanks!

Sign In or Register to comment.