BoschAccel Tap Bug?

Hi after upgrading to the API v3 the tap detector has gone wonky on me. From a single tap it sometimes return 2 null types and then a TapType.SINGLE and also I get this error. I'm using the template given in the v3 docs

Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.mbientlab.metawear.data.TapType.ordinal()' on a null object reference

Comments

  • edited March 2017
    How were you configuring the tap detection with the previous API? Also what board and firmware are you using?
  • I had it configured similar to the template. I'm using AcceleratorBmi160 running the 1.2.5
  • edited March 2017
    Please post the code you were using with api v2 and v3, specifically, all the calls to configure the accelerometer and tap detection.

    What board are you using again?  BMI160 is the IMU not the board.
  • Sorry I am using the Meta Wear CPRO – 10 Axis IMU.

    I tried running a clean install using the template given here: https://mbientlab.com/androiddocs/latest/accelerometer_bosch.html and still am having the same issues
  • I need the code you were using with API v2 since you said this issue occurred once you upgraded to v3.  Please post that code.  Are you configuring things such as odr and range along with tap detection?  If so, post that code as well.

    The code snippet works fine for me on both a CPro and RPro board when run as is, no other accelerometer calls.
  • I tried downloading the starter template on another computer and using the exact template given for the tap detection in the docs and I'm still having the issue. It also takes multiple taps to register once:
    Here's the information:

    03-09 13:24:41.310 28965-29082/com.mbientlab.metawear.tutorial.starter I/MainActivity: Single tap
    03-09 13:24:41.350 28965-28976/com.mbientlab.metawear.tutorial.starter W/BluetoothGatt: Unhandled exception in callback
    java.lang.NullPointerException: Attempt to invoke virtual method 'int com.mbientlab.metawear.data.TapType.ordinal()' on a null object reference
    at com.mbientlab.metawear.tutorial.starter.DeviceSetupActivityFragment$2$1.apply(DeviceSetupActivityFragment.java:123)
    at com.mbientlab.metawear.impl.DeviceDataConsumer.call(DeviceDataConsumer.java:51)
    at com.mbientlab.metawear.impl.StreamedDataConsumer$2.onResponseReceived(StreamedDataConsumer.java:123)
    at com.mbientlab.metawear.impl.JseMetaWearBoard$5.onMwNotifyCharChanged(JseMetaWearBoard.java:576)
    at com.mbientlab.metawear.android.BtleService$1.onCharacteristicChanged(BtleService.java:193)
    at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:485)
    at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
    at android.os.Binder.execTransact(Binder.java:453)
  • Are you testing with a board that is in a clean state or has your board been configured by other apps and is in an unknown configuration?

    Also, please post your api v2 code.
  • My board AFAIK is in a clean state. I have attempted to restart it (presuming thats what the white button does).

    I no longer have my api v2 code and am now attempting to do it on a new computer. Here's the code I have:

    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
    metawear = ((BtleService.LocalBinder) service).getMetaWearBoard(settings.getBtDevice());
    final AccelerometerBmi160 accbmi160 = metawear.getModule(AccelerometerBmi160.class);

    // enable single tap detection
    accbmi160.tap().configure()
    .enableSingleTap()
    .threshold(2f)
    .shockTime(TapShockTime.TST_50_MS)
    .commit();
    accbmi160.tap().addRouteAsync(new RouteBuilder() {
    @Override
    public void configure(RouteComponent source) {
    source.stream(new Subscriber() {
    @Override
    public void apply(Data data, Object... env) {
    AccelerometerBmi160.Tap tap = data.value(Tap.class);
    switch(tap.type) {
    case SINGLE:
    Log.i("MainActivity", "Single tap");
    break;
    case DOUBLE:
    Log.i("MainActivity", "Double tap");
    break;
    }
    }
    });
    }
    }).continueWith(new Continuation() {
    @Override
    public Void then(Task task) throws Exception {
    accbmi160.tap().start();
    accbmi160.start();
    return null;
    }
    });
  • and my relevant imports:

    import com.mbientlab.metawear.module.AccelerometerBosch.Tap;
    import com.mbientlab.metawear.module.AccelerometerBosch.TapShockTime;
    import com.mbientlab.metawear.module.AccelerometerBmi160;
  • The white button does not reset the board; either remove the battery, use the Debug module to issue a reset command, or use the MetaWear app to also issue the reset command.
  • Oh wow all I had to to was turn the power off and on... Embarrassing...

    Thanks for the patience Eric
  • Actually that did not work. I thought it did until I enabled the double tap and now I'm still receiving the same error. I tried removing the battery and using the app
  • You'll need to play around with the double tap configuration to find what works for your use case.  For the moment, you can also add a null pointer check to discard Tap objects with a null tap type.
This discussion has been closed.