Search code examples
javaandroidmicrosoft-band

Microsoft Band 2 Data stops streaming for accelerometer and gyroscope


I have been developing an Android app to track eating throughout the day. We have not decided on which sensors to use yet, so the app is capable of connecting to all of the sensors from a Service and streaming them for an indefinite amount of time, depending on when the phone decides to clean up the app's resources. What I have noticed during reliability testing is that accelerometer and gyroscope cut out after two to three minutes when they are both streaming at medium or high frequency. I have implemented a timeout thread that checks for the last received accel or gyro data (depending on if they are supposed to be streaming) and re-registers new listeners if they stopped streaming. Is anyone else having this issue and/or does anyone have recommendations for a less battery intensive way of reliable acc/gyro streaming?

To summarize:

  • Registered accelerometer and gyroscope listeners stop receiving data after 2-3 minutes
  • This only happens when streaming accel/gyro at the medium and high frequency settings and only when accel and gyro are both streaming
  • This happens regardless of whether other sensors are streaming or not
  • No exception is thrown when this happens
  • Subscription/unsubscription as well as incoming data are all handled on new threads
  • I have a hacky timeout thread that unregisters and registers new listeners for accel/gyro if they stop streaming

Questions:

  1. Is anyone else running into this issue?
  2. Is there an issue with using new Threads to handle the data that would be causing the listeners to be unregistered (unlikely because other data works implemented this way)?
  3. Is there a better (more battery efficient) way of detecting an event not occurring and responding to that than having a thread check for a timeout?

Thanks in advance!


Solution

  • Four things.

    1) The Microsoft Band gyro sensor data on the SDK includes the accelerometer data, so you should never need to subscribe to both at the same time.

    2) Subscribing to either over a long time will drastically drain the battery life of whatever band is being connected to and is thus not advised.

    3) Streaming requires that a connection to Microsoft Health's BandService remains active. And if that connection is lost, you will no longer get data. (Likely this is what is happening in your case)

    4) Microsoft has a cloud API that might be more useful for what you want to do. http://developer.microsoftband.com/cloudAPI