Fit Contributor

Hi,

just a question to the FitContributor: If I calculate the average values of an high-intensity period of an interval and write those values to the Fit file, does Garmin connect web make those values somehow visible or is it just a value in the Fit file?
  • This is covered in the programmer's guide... here.
  • Thanks for that information. I have coded this now:

    In the resources file:
    <fitContributions>
    <fitField id="0" displayInChart="true" sortOrder = "0" precision="0" chartTitle="@Strings.AvHrGraphLabel" dataLabel="@Strings.AvHrGraphLabel" unitLabel="@Strings.AvHrUnits" fillColor="#FF0000"/>
    </fitContributions>


    In the View file:
    function setupField(session) {
    avHrField.session.createField("average_heartrate", 0, FitContributor.DATA_TYPE_UINT8, { :mesgType=>Fit.MESG_TYPE_RECORD, :units=>"bpm" });
    }


    and in the compute(info) method:

    hiAvHrField = sumOfLapHr / numOfLapSamples;
    avHrField.setData(hiAvHrField.toNumber());


    Nevertheless, if I execute the code in the simulator I get this message for the setData line:

    Failed invoking <symbol>
    Unexpected Type Error


    What am I doing wrong? Note that the hiAvHrField will never reach 255, therefore IMO the DATA_TYPE_UINT8 should be fine.
  • The object you call setData() on should be an object returned from createField().
  • OK, thanks for that information. I had a type error in my code. The correct code is:
    function setupField(session) {
    avHrField = session.createField("average_heartrate", 0, FitContributor.DATA_TYPE_UINT8, { :mesgType=>Fit.MESG_TYPE_RECORD, :units=>"bpm" });
    }


    Nevertheless, when is the setupField method called from the OS? I belief that the function is not called at all.
  • No, the setupField() function that you snipped from the programmer's guide is just an example. Nothing calls it. If you need an example, the MoxyDataField sample program included with SDK should have everything that you need.

    Travis
  • OK, got it running, at least got it compiler clean. I created a .prg file and tried out the datafield but the graph is not shown in GC web. The fitContributor needs to get a certain permission. Can it be that the permission is not given if one sideloads the datafield?
  • The data won't appear in Garmin Connect until you upload your app to the app store. If you're not ready to upload to the store, you should be able to use the monkeygraph utility to display the data from fit files captured in the simulator and from the device.
  • Travis, you are really the best. I have tried monkeygraph out and the data is shown there. Many thanks to you for getting this running. My datafield will goes live in some days not least due to your help.
  • Hi,

    just another question. I tried to write a string at the end of my workout to the .FIT file. The compiler did not complaint but in the end of the simulation I get following failure:

    setData string too long for allocated space


    The API says nothing about string length limitations. My string had 32 characters....