FitContributor custom filed: how to visualize it in Garmin Connect?

Hello,

In my DataField I write to the FIT-File.
// Create the custom FIT data field we want to record.
verticalSpeedFitField = DataField.createField(
"vertical_speed",
VERTICALSPEED_FIELD_ID,
Fit.DATA_TYPE_UINT16,
{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>"m/h"}
);
verticalSpeedFitField.setData(0);

//and onceASecond with
verticalSpeedFitField.setData(myVerticalSpeed.toNumber());


The goal is to see a graph with these values in The Garmin Connect Activities (https://connect.garmin.com/modern/activities)

But I cant see anything from my VerticalSpeed there!

What more do I have to do to make this happen?

Tks
  • You need to:

    - Add the information about your FitContributor field to the app XML (*)
    - Submit your app to the store (sideloaded apps won't show FitContributor values -- you can see the graph during testing by using the MonkeyGraph tool from the SDK)

    Also, there have been on-and-off again issues with displaying developer fields in either the mobile app or the website. These seem to be mostly fixed by now, but just in case check in both the app and the website.

    (*) e.g.
    https://developer.garmin.com/index.php/blog/post/connect-iq-2-the-full-circle
    First, you must enable the FitContributor permission in the manifest file. Next, you need to add your field definitions in your resources using the fitContributions block:
    <strings>
    <string id="namaste_label">Namastes</string>
    <string id="namaste_graph_label">Namastes</string>
    <string id="namaste_units">N(s)</string>
    </strings>
    <fitContributions>
    <fitField id="0" displayInChart="true" sortOrder = "0" precision="2"
    chartTitle="@Strings.namaste_graph_label" dataLabel="@Strings.namaste_label"
    unitLabel="@Strings.namaste_units" fillColor="#FF0000" />
    </fitContributions>

  • Thanks, but still not working...

    I added a resource.xml to the folder resoures:

    <fitContributions>
    <fitField id="0" displayInChart="true" sortOrder = "0" precision="2"
    chartTitle="@Strings.namaste_graph_label" dataLabel="@Strings.namaste_label"
    unitLabel="@Strings.namaste_units" fillColor="#FF0000" />
    </fitContributions>




    The ID =0: (should therefore be correct.
    const VERTICALSPEED_FIELD_ID = 0;

    the permission is set in the manifest.xml

    -I downloaded it via the shop to the watch,
    -started an app witch contains this DataField,
    -Sync to Garmin Connect,
    where I can see my activity but this fitField!!

    Any hint?




  • That was just an example and I'm not sure how much you actually used. You need to define the strings for the chart title, data label and unit label. I'm guessing you already did that otherwise you would get a build error, but I would expect your actual code to look more like this:

    <strings>
    <string id="vspeed_label">Vertical Speed</string>
    <string id="vspeed_graph_label">Vertical Speed</string>
    <string id="vspeed_units">m/h</string>
    </strings>

    <fitContributions>
    <fitField id="0" displayInChart="true" sortOrder = "0" precision="2"
    chartTitle="@Strings.vspeed_graph_label"
    dataLabel="@Strings.vspeed_label"
    unitLabel="@Strings.vspeed_units"
    fillColor="#FF0000" />
    </fitContributions>


    As I mentioned, it would help if you use the MonkeyGraph tool in the SDK to test locally:
    1) In simulator, record FIT file with your app.
    Simulation > Simulate Data
    Data Fields > Timer > Start Activity
    Data Fields > Timer > Stop Activity
    Data Fields > Timer > Save Activity (this is important)
    Simulation > Save FIT session

    2) In Eclipse, export IQ file for app
    Connect IQ > App Export Wizard

    3) Start monkeygraph
    Connect IQ > Start monkeygraph

    Open both the IQ file and the FIT file. Make sure that you see a graph; if not, you know that something is already wrong before you even upload the app to the store and test with Garmin Connect.

    Also, are you sure you don't want your FIT field to be a float type and not UINT16? I'm guessing that the vertical speed in metres per hour is not always going to be an integral value.

    And, I assume that your initialization code (createField, etc.) happens your data field initialize() function. If you do it at some other point (for whatever reason), it won't work (I've tried it -- long story).

  • Hello FlowState,
    Tks for your help

    It is working now!
    Seems it had a problem with type. string or INT, I do not know so exaclty.

    VerticalSpeed is rounded to 50 ex 450m/h. so I choosed SINT16

    had to use ToNumber.()

    So code is:

    function initialize()
    {
    DataField.initialize();


    // Create the custom FIT data field we want to record.
    verticalSpeedFitField = DataField.createField(
    "vertical_speed",
    VERTICALSPEED_FIELD_ID,
    Fit.DATA_TYPE_SINT16, // +/- 32767
    {:mesgType=>Fit.MESG_TYPE_RECORD, :units=>"Up m/h"}
    );
    verticalSpeedFitField.setData(0);
    }


    OnUpdate...
    verticalSpeedFitField.setData(myVerticalSpeed.toNumber());

  • Hey, glad it's working for you now, although I wasn't much help. Your code in the OP had toNumber so I'm not sure what else is different except SINT16 instead of UINT16. Anyway, I should've mentioned that recording seems to silently fail if there's a type mismatch, but it's working now so it's all good.
  • You were a big help for the MonkeyGraph and the resource.xml.
    It saved me probably a lot of time.
    It is now in : https://apps.garmin.com/en-US/apps/1cc6cbe8-d655-4956-b870-54eea8bf9c6d
    Thank you
  • The vertical speed is only saved to FIT, when this DataField is active on the watch (visible).
    Otherwise it seems, that it goes to sleep. So in the graph I have "data holes", were the DataField was not active.
    Is there a workaround?
  • You want to do the data save in compute() and not in onUpdate(). Compute is called every second if the DF is visible or not, but onUpdate is only called when the DF is visible..
  • Thanks a lot, that was very useful.However my field is showing in garmin connect, but not in monkey graph. Thks Pierre