Is there Kotlin documentation at all? I'm getting a Bluetooth Exception I need help debugging

I tried to get Acceleration data out of my MetaMotion R and I'm getting a bluetooth exception I don't quite understand.

` fun startGettingAccelerationData() {
try {
accelerometer = metaWearBoard.getModule(AccelerometerBmi160::class.java)
Timber.d("METAWEAR Accelerometer: %s", accelerometer)
accelerometer.configure()
.odr(AccelerometerBmi160.OutputDataRate.ODR_25_HZ) // set odr to 25Hz
.range(AccelerometerBosch.AccRange.AR_4G) // set range to +/-4g
.commit()

        accelerometer.acceleration().addRouteAsync {  }

        accelerometer.acceleration().addRouteAsync(RouteBuilder { source ->
            source.stream(object : Subscriber {
                override fun apply(data: Data?, vararg env: Any?) {
                    data?.let {
                        val acceleration: Acceleration = it.value(Acceleration::class.java)
                        Timber.d("METAWEAR - Data %s", acceleration.toString())
                    }
                }
            })
        }).continueWith(object : Continuation<Route, Void> {
            @Throws(Exception::class)
            override fun then(task: Task<Route>): Void? {
                accelerometer.start()
                return null
            }
        })
    } catch (exception: Exception) {
        Timber.e(exception)
    }
}`

And here's the exception I get when I try to run it this way:

2019-08-13 00:44:50.682 21820-21962/com.onepeloton.studio.dev W/BluetoothGatt: Unhandled exception in callback java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter env at com.testapp.sample.MetawearSensorReceiver$startGettingAccelerationData$1$1.apply(Unknown Source:7) at com.mbientlab.metawear.impl.DeviceDataConsumer.call(DeviceDataConsumer.java:51) at com.mbientlab.metawear.impl.StreamedDataConsumer.lambda$addDataHandler$4(StreamedDataConsumer.java:155) at com.mbientlab.metawear.impl.-$$Lambda$StreamedDataConsumer$b3JFDLkGI0Pi2mtR2I-nobGuhUc.onResponseReceived(Unknown Source:4) at com.mbientlab.metawear.impl.JseMetaWearBoard.lambda$null$17(JseMetaWearBoard.java:796) at com.mbientlab.metawear.impl.-$$Lambda$JseMetaWearBoard$OnC0yYpmZcKMMHqzlWEtJ-kw-x8.onChange(Unknown Source:2) at com.mbientlab.metawear.android.BtleService$1.onCharacteristicChanged(BtleService.java:179) at android.bluetooth.BluetoothGatt$1$8.run(BluetoothGatt.java:519) at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:876) at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:43) at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:513) at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:185) at android.os.Binder.execTransact(Binder.java:739)

Comments

  • edited August 13

    Stack trace tells you what is wrong.
    kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter env at com.testapp.sample.MetawearSensorReceiver$startGettingAccelerationData$1$1.apply(Unknown Source:7)

Sign In or Register to comment.