Trouble logging data

Hi there,

I'm trying to log accelerometer and gyroscope data on the MetaMOTION R. It would be at a rate of 25Hz for roughly 20 minutes so I don't think memory is an issue. However, I can only get streaming to work. This is the code when logging starts:
mAccelerometer = mMetaWearBoard.getModule(AccelerometerBmi160.class);
mLogging = mMetaWearBoard.getModule(Logging.class);
mAccelerometer.configure()
.odr(25f)
.range(4f)
.commit();
mAccelerometer.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.log(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("MainActivity", data.value(Acceleration.class).toString());
}
});
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
mLogging.start(true);
mAccelerometer.acceleration().start();
mAccelerometer.start();
return null;
}
});
This is the code when logging ends:
mLogging.stop();
mAccelerometer.stop();
mLogging.downloadAsync(100, new Logging.LogDownloadUpdateHandler() {
@Override
public void receivedUpdate(long nEntriesLeft, long totalEntries) {
Log.i("MainActivity", "Progress Update = " + nEntriesLeft + "/" + totalEntries);
}
}).continueWith(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
Log.i("MainActivity", "Download completed");
return null;
}
});
mLogging.clearEntries();
mMetaWearBoard.tearDown();
I get the "Download completed" log but I'm not getting any of the log data. I'm also getting this warning from the Android logs after the download is 'completed'. Any help or advice would be appreciated.

06-01 14:10:26.188 15747-15781/wisdm.cis.fordham.edu.metaweardatacollection W/BluetoothGatt: Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'void bolts.TaskCompletionSource.setResult(java.lang.Object)' on a null object reference
at com.mbientlab.metawear.impl.LoggingImpl$4.onResponseReceived(LoggingImpl.java:260)
at com.mbientlab.metawear.impl.JseMetaWearBoard$5.onMwNotifyCharChanged(JseMetaWearBoard.java:579)
at com.mbientlab.metawear.android.BtleService$1.onCharacteristicChanged(BtleService.java:193)
at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:443)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
at android.os.Binder.execTransact(Binder.java:446)

Comments

    • What version of the API are you using?
    • Add error handling to the addRouteAsync task and see if it was successful.
  • I am using 3.0.32. I tried 3.0.0 as well but it has no effect on the issue. If you don't mind, could you explain what kind of error handling I would need to implement?
  • Thanks, Eric. Tried that but still the same issue. Is there a sample project that uses 3.0.0 or 3.0.32 that I could look at? I've searched quite a lot but no luck.
  • Did the task succeed?  Based on what you have said, the task should be failing, and if that is indeed the case, then post the stack trace.

    We have a few tutorial apps on our GitHub page.  The freefall app demonstrates using the logger.
  • It says the task succeeded. I was hoping it would fail with a stack trace so this is weird. I'll try looking at that tutorial and get back to you. 
  • Looking at your code again, you start a log download, then immediately tell the logger to clear all entries.  Remove the clearEntries call.
  • Thanks Eric. I got the logger to work by looking more carefully at the freefall tutorial. 

    One question though - I want to connect to multiple metawear sensors and stream/log accelerometer and gyroscope data for 20-30 minutes at a time (at around 25Hz). Would streaming or logging be more appropriate? I feel that the 8MB of flash memory would be enough to log but what do you think? I do need all the raw data so filtering is not an option.
  • Depends on how many is "multiple".  Streaming 2 or 3 should be fine but your mileage may vary if you try more depending on your Android device and OS.
This discussion has been closed.