When I use the account() in my code, I cannot get data more than the second connect.

Board Information

I have several MetaWears and they all are in the same situation.
I will describe two board information of them.

  • MetaMotion R
    . Hardware revision: 0.4
    . Firmware revision: 1.5.0
    . Model number 5
  • MetaMotion C
    . Hardware revision: 0.2
    . Firmware revision: 1.5.0
    . Model number 6

Host Device Information

  • Device model: Samsung Galaxy Z Flip
    OS version: Android 10 / security patch April 1, 2020

Issue

  • What is the expected behavior?
    I should get data with the timestamp writen by a sensor

  • What is observed behavior?

    1. When I use the account() for the source in the addRouteAsync(),
      I just can get data from the sensor for the first session.
      After disconnection, if I try to connect and get data again with account(),
      I cannot get any data from sensor.
      I tried it several times with the same metawear, and other metawears.
      The same things happened all the times.

    2. Strange thing is that:
      If I update the firmware of the metawear (but the version(1.5.0) is not changed),
      I can get data with the timestamp (using account() in the code) just for the first connection,
      after that, I cannot.

The below is my abstract code snippet.

  • I always got the following message, "account() set is succeeded???"
  • so, I think the connection is not the problem
class MbientSensorVisitor(var board: MetaWearBoard) : SensorVisitor {
   override fun start(myAccelerometer: MyAccelerometer) {
        var accelerometer =  board.getModule(Accelerometer::class.java)
        accelerometer.configure()
        accelerometer.acceleration().addRouteAsync({ source ->
            source.account().stream({ data, env ->
                val value = data.value(Acceleration::class.java)
                myAccelerometer.addData(
                    AccelerationData(
                        data.timestamp().timeInMillis,
                        floatArrayOf(value.x(), value.y(), value.z())
                    )
                )
            })
        }).continueWith({
            accelerometer.acceleration().start()
            accelerometer.start()
            return@continueWith null
        }).continueWith({
            if (it.isCompleted()) {
                Log.d(TAG, "###################")
                Log.d(TAG, "account() set is succeeded???")
            }
            if (it.isFaulted()) {
                Log.d(TAG, "###################")
                Log.d(TAG, "account() set is failed!!!!")
            }
            if (it.isCancelled()) {
                Log.d(TAG, "###################")
                Log.d(TAG, "account() set is cancelled!!!!")
            }
        })
    }

    override fun config(cheerupAccelerometer: CheerupAccelerometer) {
        var accelerometer =  board.getModule(Accelerometer::class.java)
        accelerometer.configure().odr(50f).range(16f).commit()
    }
}

Development environment

  • SDK version: 3.7.1
  • Ubuntu 18.04 / Android Studio 3.6.3

Comments

  • May I get some information about this issue?

  • https://mbientlab.com/androiddocs/3/metawearboard.html#tear-down

    Also, your code doesn't check if creating the data route succeeded or not, it just checks if the issuing the accelerometer commands did, which it always does. NJ

  • @Eric

    Thank you, Eric.
    I could get the timestamp from sensors, when I used source.account() after made the sensor clear with tearDown().
    But, I cannot find how to check if creating the data route succeeded or not.
    Could you please let me find the example code for it?

Sign In or Register to comment.