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
Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.mbientlab.metawear.data.TapType.ordinal()' on a null object reference
This discussion has been closed.
Comments
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
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)
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;
}
});
import com.mbientlab.metawear.module.AccelerometerBosch.Tap;
import com.mbientlab.metawear.module.AccelerometerBosch.TapShockTime;
import com.mbientlab.metawear.module.AccelerometerBmi160;
Thanks for the patience Eric