Heading does not work when recording activity

Former Member
Former Member
When I start recording an activity I notice that the heading
From sensorinfo no longer works. Once I stop the activity recording
Then I am able to read heading information. This is happening
On the fenix 3. Anyone aware of this problem or a workaround?

Thanks
Jesus
  • Former Member
    Former Member over 8 years ago
    Reposting with code tags. I just noticed that the heading lock also happens without GPS enabled. It locks once I start the activity recording, even if not using GPS.

    enum {
    FIT_STATE_GPS_ON = 0,
    FIT_STATE_GPS_READY = 3,
    FIT_STATE_SURFACE_SESSION_CREATE = 5,
    FIT_STATE_SURFACE_SESSION_START = 8,
    FIT_STATE_SURFACE_SESSION_DISCARD = 128,
    FIT_STATE_DIVING
    }

    var barometer;
    var fitState;
    var session;
    var heading;

    class DiveComputerApp extends App.AppBase
    {
    function onStart(state)
    {
    gpsOn();
    }

    function timerHandler()
    {
    if (session != null && session.isRecording()) {
    systrace("-event READING_SENSORS");
    var info = Activity.getActivityInfo();
    barometerBars = barometer.getBars(info.altitude);
    heading = info.currentHeading;
    }
    }

    function gpsOn()
    {
    systrace("-event GPS_ON");
    fitState = FIT_STATE_GPS_ON;
    Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
    }
    }

    function onPosition(info)
    {
    if (fitState < FIT_STATE_GPS_READY) {
    if (info.accuracy == Position.QUALITY_GOOD || info.accuracy == Position.QUALITY_USABLE){
    fitState++;
    }
    } else if (fitState == FIT_STATE_GPS_READY) {
    systrace("-event GPS_READY");
    fitState++;
    } else if (fitState < FIT_STATE_SURFACE_SESSION_CREATE) {
    fitState++;
    } else if (fitState == FIT_STATE_SURFACE_SESSION_CREATE) {
    sessionCreate();
    fitState++;
    } else if (fitState < FIT_STATE_SURFACE_SESSION_START) {
    fitState++;
    } else if (fitState == FIT_STATE_SURFACE_SESSION_START) {
    sessionStart();
    fitState++;
    } else if (fitState < FIT_STATE_SURFACE_SESSION_DISCARD) {
    fitState++;
    } else if (fitState == FIT_STATE_SURFACE_SESSION_DISCARD) {
    sessionDiscard();
    fitState = FIT_STATE_GPS_ON;
    }
    }

    function sessionCreate()
    {
    systrace("-event FIT_SESSION_CREATE");
    session = Fit.createSession({:name=>"Scuba", :sport=>Fit.SPORT_SWIMMING,
    :subSport=>Fit.SUB_SPORT_OPEN_WATER});
    depthField = session.createField("Depth", 0, FitContributor.DATA_TYPE_FLOAT,
    {:mesgType=>FitContributor.MESG_TYPE_RECORD, :units=>"Depth"});
    maxDepthField = session.createField("MaxDepth", 1, FitContributor.DATA_TYPE_FLOAT,
    {:mesgType=>FitContributor.MESG_TYPE_SESSION, :units=>"Depth"});
    }

    function sessionStart()
    {
    systrace("-event FIT_SESSION_START");
    session.start();
    }

    function sessionStop()
    {
    systrace("-event FIT_SESSION_STOP");
    session.stop();
    }

    function gpsOff()
    {
    systrace("-event GPS_OFF");
    Position.enableLocationEvents(Position.LOCATION_DISABLE, null);
    }

    function sessionSave()
    {
    systrace("-event FIT_SESSION_SAVE");
    session.save();
    session = null;
    depthField = null;
    maxDepthField = null;
    gpsOn();
    }

    function sessionDiscard()
    {
    if (session == null) {
    return;
    }
    systrace("-event FIT_SESSION_DISCARD");
    session.discard();
    session = null;
    depthField = null;
    maxDepthField = null;
    }

    function systrace(log)
    {
    Sys.println("-time " + Sys.getTimer()/1000 + " " + log);
    }
  • I'm not surprised heading is "locked" without GPS. If it's using GPS for heading, it will only change when you're moving, and to see which way you're moving, it needs a pair of lat/lon to figure that out.

    I've been fully understood if a HW Compass (if available) is used at all with heading, or if it's only used when your not moving, or moving below a certain speed. From what I see on a va-hr, it seems it's not used at all for heading - only GPS is used.
  • Former Member
    Former Member over 8 years ago
    Jim,

    If I disable activity recording it works, so I am sure a GPS is not needed.
    On top of that I've noticed that it "sometimes" works even with activity recording and GPS enabled. Recall how I explain that every two minutes restart a new session? We'll, I observed that it works for the first session, not for second, works for the third, not for the fourth, and so on. So weird. This is driving me nuts !

    Jesus
  • You've tried my app and don't see the problem, so I'm out of ideas.

    When you say it works every other time, are you restarting your app each time, or just starting a new session? What do things look like when you upload to Garmin Connect?
  • Former Member
    Former Member over 8 years ago
    Have you tried using a sport other than swimming for you session yet? We are investigating, but suspect some undesired system behavior could be related to this sport type.

    Also, I am curious if you are actually receiving a heading value that does not change, or if the value is returning 'null' in this case, and your app is holding onto the previous value as a result.
  • Former Member
    Former Member over 8 years ago
    Brian, I have tried other sports (I've tried everything :-)) and same results. I receive a heading value that does not change. If you look into this, I am willing to write a barebones app with the minimum amount of lines that would reproduce this issue. Would iit help? Let me know if you are interested and Ill start working on it.

    Thanks so much
    jesus
  • Former Member
    Former Member over 8 years ago
    Brian, I have tried other sports (I've tried everything :-)) and same results. I receive a heading value that does not change. If you look into this, I am willing to write a barebones app with the minimum amount of lines that would reproduce this issue. Would iit help? Let me know if you are interested and Ill start working on it.

    Thanks so much
    jesus


    I talked to one of our sensor team guys last Friday, and he is investigating. (Connect IQ requests this data directly from their module.) I don't think we need anything at this time, but I will let you know if he has trouble reproducing the issue and would like a test app.
  • @Brian. What confuses me, is that Jesus downloaded one of my apps to his watch and says that heading is working fine (same FW, same VM). I use "currentHeading" in Activity.info.

    It records as "SPORT_WALKING" and defaults the subSport. Here's the link in the store if you need something that works fine:

    https://apps.garmin.com/en-US/apps/028c5a06-48ed-4a5d-9910-236a7ef10ce0

    Let me know if you want the source. (The "no laughing at my code" rule applies! :) )

    I am looking at some oddness with "heading" in Position.Info (continuous mode) with no recording session though....
  • Former Member
    Former Member over 8 years ago
    @Brian. What confuses me, is that Jesus downloaded one of my apps to his watch and says that heading is working fine (same FW, same VM). I use "currentHeading" in Activity.info.

    It records as "SPORT_WALKING" and defaults the subSport. Here's the link in the store if you need something that works fine:

    https://apps.garmin.com/en-US/apps/028c5a06-48ed-4a5d-9910-236a7ef10ce0

    Let me know if you want the source. (The "no laughing at my code" rule applies! :) )

    I am looking at some oddness with "heading" in Position.Info (continuous mode) with no recording session though....


    The only difference I can identify between Jim's app and my app is that Jim's app requires user input to start the activity while in my app it is done automatically.

    Jesus
  • Just to update everyone on this, Jesus was able to help us figure out that there is a unique case where recording with SUB_SPORT_OPEN_WATER will not allow you to access the heading info using Activity.info. I've adjusted our ticket and we will be looking into it going forward big thanks to Jesus! :D

    -Coleman