Writing to .fit files from a datafield app

Hi,

I've published a first version of a data field for garmin 920xt, and wonder if it will be possible to write data to the .fit file from tha IQ SDK.

Regards and thanks for IQ, it's great !

Rafael
  • There is an ActivityRecording API available to the App type application, which records data to FIT files. Data fields run in the context of another activity, so they don't have the ability to record FIT files themselves--they just display information in new ways, though the activity in which the data field runs records as it normally would.
  • Yeah, but an app type application has to override a complete garmin app ;-). I just want the datafield to be able to write a record, hope garmin add this in the near future ;-). Regards,
  • I'm trying to get this to work as well. I followed the bananas earned example on this page:

    https://developer.garmin.com/connect-iq/api-docs/Toybox/FitContributor.html

    but no data is saved for my custom datafield after the activity (walk) is completed and saved.  Is there something else that I need to do?  Also I set the field ID to 0, but how do I know if this conflicts or not with an existing ID that may be being used , custom or native?

  • You need to createField(), and make sure you have the data you want for that field at all times using setData() (I do it in compute() on every call.)

    You need to have the xml file that defines how that data will be displayed in Garmin Connect, and for that data to be displayed, the DF needs to be installed from the app store.

    As far as the field ID, it's really not just a 0.  It's a combo of that plus your app ID, so it's only got to be unique in your data field.

  • Thanks,

    Can you explain this more ? ==>

    >> You need to have the xml file that defines how that data will be displayed in Garmin Connect, and for that data to be displayed

    Do I need to create an XML file or does the user do it somehow manually or automatically?

  • It's used when you compile to build the fit_contributions.jso which is included in the iq file for the store.

    For example, in a DF initialize(), I have this:

    field=createField("piTemp",0,FitContributor.DATA_TYPE_FLOAT, {:mesgType => FitContributor.MESG_TYPE_RECORD}); 

    in compute, this:

    field.setData(tempValue);

    And the fitContrib.xml has this:

    <resources>
        <strings>
        	<string id="temp_label">Temp</string>
        	<string id="temp_units">F</string>
        	<string id="temp_title">piTemp</string>
        </strings>
        
         <fitContributions>
            <fitField id="0" displayInChart="true" chartTitle="@Strings.temp_title" fillColor="ff0000" sortOrder = "1" precision="2" displayInActivityLaps="false"
            dataLabel="@Strings.temp_label"
            unitLabel="@Strings.temp_units"/>
         </fitContributions>
    </resources>

    The result is this graph:

  • I think I followed everything required.  I looked in the iq file and there is no fit_contributions.jso file.  What could be the cause?

  • It will be in a folder for a part number along side the prg.

    Where do you have your xml file?  Induce an error in it and rebuild your app.  It will give you a warning/error if it's in the proper place.

  • I looked in a couple of the part number folders.  Just to be clear, I have to manually create fitContrib.xml right?  Where do I put it?   The documentation is not clear on this.

  • He goes under resources.  Here's what I often do:

    The fitcontrib.xml is what I posted a while back.  It's app specific so you need to do your own.