Logging

The Logging class interacts with the logger, which stores sensor data to the on-board flash memory.

Starting the Logger

To start logging, call the startLogging method. If you wish to overwrite existing entries, use the overloaded method instead.

import com.mbientlab.metawear.module.Logging;

final Logging logModule= mwBoard.getModule(Logging.class);

// start logging, if log is full, no new data will be added
logModule.startLogging();

// start logging, if log is full, overrite existing data
logModule.startLogging(true);

Downloading Data

When you are ready to retrieve the data, call the downloadLog method. The method takes in a DownloadHandler, which handles notifications from the logger, and how often to send progress updates to the user. It also returns an AsyncOperation object that contains the number of entries to download.

// Start downloading the log
// All MessageHandlers passed to setLogMessageHandler will be called
logModule.downloadLog(new Logging.DownloadHandler() {
    @Override
    public void onProgressUpdate(int nEntriesLeft, int totalEntries) {
        Log.i("MainActivity", String.format("Progress= %d / %d", nEntriesLeft,
                totalEntries));
    }
});