Data Field resets to zero when Heart Rate monitor loses signal

Former Member
Former Member

I've got a data field that computes an ongoing tally of glycogen use and the only input it uses is info.currentPower.  When I stop and walk away from the bike/device and return to it, this data field zeros out.  I've found that this occurs when the heart rate monitor loses connection with the device and then reconnects.  What i can't figure out is, my app doesn't use any HR data, so why is that reconnection event causing the calculation to reset? 

  • Ok a couple things..

    Wouldn't currentPower drop to zero when you stop? As that's the only data you use, I think that's the case.

    Is this an edge device on your bike and the HR disconnected when you get out of range and reconnected when you return?  The two things probably aren't related.

    Are you pausing the recording when you stop and use that state in your DF?

  • Former Member
    Former Member over 6 years ago

    Former Member - I wanted to let you know that I've reached out to you in an email. Thanks!

  • I realise this thread is four years old, but I'm experiencing the exact same thing, and this is the only forum post I could find that is relevant.

    Twice, my Endurance in Zone app (https://apps.garmin.com/en-US/apps/95fc3b69-6c3c-4618-a2de-f68ffca35360) has reset its data while out on a ride. Both times, it happened when I was stopped and moved out of range with my heart rate belt. My power pedal disconnecting after a few minutes idle may also be relevant.

    I tested a little at home now. Just losing contact with the heart rate sensor or the power pedal seems fine. But when I lose contact with the HR first and then the power pedal later, both my data field and an Xert data field reset themselves.

    I need to fix this, but I don't know why. After it happened the first time, I thought it might have to do with suspend and resume, so I implemented that (although it is hard to test if it works), but this is still happening.

  • In my DF when I 1st connect to an ANT HRM i save it's ant id and then a) only connect to it in the same session, b) i don't know what zeros out mean, but that sounds like something that your code does, that you should skip in case of reconnecting

  • What is meant by zeroed is that the app seems to be restarted, so any local state is lost. My app counts time in a given power or heart rate zone. When state is lost, it looks like the user has done 0 time in zone.

    Connecting any sensors shouldn't cause the app to restart, but I will debug onSensor and see if I find something interesting.

  • I did some logging, and got some interesting results:

    21:15:28: onUpdate
    21:15:29: compute
    21:15:30: onUpdate
    21:15:30: compute
    21:15:31: onStop
    21:15:31: EnduranceInZoneApp.initialize
    21:15:31: EnduranceInZoneView.initialize
    21:15:31: onStart
    21:15:31: compute
    21:15:32: onUpdate
    21:15:33: compute
    21:15:33: compute
    21:15:34: onUpdate

    What's interesting here is that onStop is not being called with the suspend parameter, because my code does this:

    public function onStop(state) {
      log("onStop");
      if (state != null && state.get(:suspend) != null) {
        log("suspend");
        saveState(view.getState());
      }
    }
    Also, I know the app has really been terminated after onStop, and no state has been kept, because I also do this:
    public function initialize() {
      AppBase.initialize();
      log("EnduranceInZoneApp.initialize");

      if (view != null) {
        log("view has already been initialized and will now get reset!");
      }
      view = new EnduranceInZoneView(readSettings());
    }
    Now I just need to figure out how to save and load state when this happens, but not when a normal stop and start happens.
  • Yeah, I also spent some time on figuring out the state, but I've never ever seen there anything but null in the simulator. I ended up using this function instead:

        hidden function isInActivity() as Boolean {
            var info = Activity.getActivityInfo();
            return info != null && (info as Activity.Info).startTime != null;
        }
    

    which I call both from onStart and onStop and depending on what this returns I save/resume some data.

  • Thanks! Yes, I found this trick in your other thread about onStop and suspend. It's a good idea!