Switching between logging/streaming depending on connection state.

Hi, apologies if this has been asked before, I've tried looking and haven't been able to find the answer.

I am trying to develop an application that takes data from the step detection routine of the Bm160 accelerometer. What I'd like to do is to be able to switch on logging for step detection when the board disconnects, then when the board reconnects to the phone, switch to streaming. So far, I've not been able to switch logging on or off depending on the connection state which means that entries appear both in the log and the stream when connected. I'm currently using just logging a periodically polling the logs but this seems inefficient versus streaming. Any help is greatly appreciated (even just letting me know that it isn't possible).

Many thanks

Board: Metawear RG
Firmware: 1.2.5

Comments

  • Create a data route with both a log and stream component.  You can program the board to stop the logger when a disconnect event is fired, and have it start the logger when connection is restored.

  • Thank you for the reply but it's the other way around that I would like things to work:
     - Stop streaming and start logging when the device disconnects
     - Stop logging and start streaming when the device reconnects

    I've tried using the stopLogger and startLogger methods in the Logging module but logging appears to happen always whether stop or start have been called. Is there any help you can give me please?

  • Confirmed with the firmware dev that the logger is always active.  Until the next firmware update, which will add a logger enable/disable so the start/stop logger calls will properly work, add a conditional Passthrough processor to the step detector and log the passthough output instead.  When a disconnect occurs, set the passthrough value to 1, and on reconnect, set the value to 0.
  • Brilliant, thanks for your help.
This discussion has been closed.