Save FIT Field correctly

Hi all,
I've a time value and I need to view it on my connect IQ activity, but it seems wrong and I don't know why (my knowledge are limited, so I discard save value as time, and save as string instead).


In a side I've FIT Field setted correclty (I think):

mTotalWaveTimeField = mSession.createField("timeOnWave", 5, FitContributor.DATA_TYPE_STRING, { :count => 32, :mesgType => FitContributor.MESG_TYPE_SESSION});
...
timeOnWave = Lang.format("$1$:$2$", [mTotalWaveTime / 60, (mTotalWaveTime % 60).format("%02d")]);
mTotalWaveTimeField.setData( timeOnWave );

In the other side I take this value (same variable timeOnWave) to present on a screen



But when I save the activity looks like:


What's wrong?? Why my value (even as string) doesn't save correctly??

How string "01:49" it converts to "3"??? I couldn't understand... same value, setData correctly... Something I'm doing very wrong...

Any help would be appreciate. Thanks in advance!

  • where are you doing the setData() call?  As part of compute()?  It's got to be done before data is written to the fit file and ongoing...

  • Hi, @jim_m_58

    I'm doing just after another one that it works...

    I've a function sensorCallback() on my classModel that I've call before session.start().

    Regards,

  • So this is a device app and not a data field?  What do you see if you use MonkeyGraph?

  • Yes, it's a device app. MonkeyGraph it's identical to GC:

    I've detect this "#VALUE?" that I don't know where it comes... maybe this is an error in my fit fields?

    thanks,

  • How are you defining stuff in the fitContributions section of your xml?

    So you have 4 fitcontrib fields in your app?

  • Yes, I've 4; 3 fields and 1 chart. So maybe this #value could be the chart, not an error....

    <fitContributions>
        <fitField
            id="1"
            displayInChart="true"
            sortOrder="0"
            precision="1"
            chartTitle="@Strings.wave_graph_label"
            dataLabel="@Strings.wave_label"
            unitLabel="@Strings.wave_units"
            fillColor="#19b5fe" />
       
        <fitField
            id="2"
            displayInActivitySummary="true"
            sortOrder="1"
            precision="-1"
            dataLabel="@Strings.wave_label"
            unitLabel="@Strings.wave_units"  />
       
        <fitField
            id="3"
            displayInActivitySummary="true"
            sortOrder="2"
            precision="-1"
            dataLabel="@Strings.wavedist_label"
            unitLabel="@Strings.wavedist_units"  />
       
        <fitField
            id="4"
            displayInActivitySummary="true"
            sortOrder="3"
            precision="-1"
            dataLabel="@Strings.wavetime_label"
            unitLabel="@Strings.wavetime_units"  />

    </fitContributions>

    Well, I couldn't detect any errors. I've debugg and this var it's correct before setData(), I don't know whats going on...

    Maybe it's difficult to find in this way...

    Thanks,

  • The ID for your "timeOnWave" field in your Monkey C code is 5, but the largest ID for for your fitContributions xml is 4 (and the field with ID 4 has dataLabel set to "@Strings.wavetime_label" which suggests it's the wave time).

    mTotalWaveTimeField = mSession.createField("timeOnWave", 5, FitContributor.DATA_TYPE_STRING, { :count => 32, :mesgType => FitContributor.MESG_TYPE_SESSION});

    <fitField
      id="4"
      displayInActivitySummary="true"
      sortOrder="3"
      precision="-1"
      dataLabel="@Strings.wavetime_label"
      unitLabel="@Strings.wavetime_units" />

    Did you mean to to pass 4 to createField() instead of 5?

  • Also, I tested a string FIT summary field in one of my own apps, and I had no problem writing things like "Set" or "1:49". The strings displayed properly in both the Garmin Connect website and the Connect app for iOS.

  • Oh f*ck.... Sob

    I'm coming to be crazy with a basic error... I've tested and you're right. Tha's it!

    Thanks a lot for your time @flowState and @jim_m_58 My fault absolutely....

    Regards,

  • No worries!

    It's interesting how the uninitialized field had a value of "3" tho. Maybe not a coincidence that sortOrder="3", although it seems like a bug if Garmin Connect (or the device firmware) would actually use the sort order as the default value of a string FIT field.