Skip to content

Custom Product Profiles

Tormod Erevik Lea edited this page Oct 31, 2015 · 6 revisions

The complete specification of types and messages for the FIT protocol is called the "Global Profile". A "Product Profile" is a subset of the Global Profile, only including a subset of type and message definitions. A custom product profile is a convenient way of controlling struct sizes and memory usage.

fit supports generating code for custom product profiles. This can be done by editing the SDK profile workbook and invoking fitgen. Every field definition with a value greater than zero in the EXAMPLE column of the Messages sheet will be included in the generated code.

The fit package will always use and update to the official FIT product profile bundled with the SDK. It would be natural to vendor the fit package if you want to use your own custom profile.

See Section 3, "Overview of the FIT File protocol" [1], for more information about FIT product profiles.

Generation Example

This sections explains how to generate a custom FIT profile.

Prerequisites

The example assumes the following:

  • $GOPATH set.
  • $GOPATH/bin in $PATH.
  • You have ran: go get -u github.com/tormoder/fit/...
  • FIT SDK Zip file available locally.

Example 1: No profile changes

If you want to make no changes to the profile (e.g. just updating to a newer SDK version), generating a profile is simple:

  1. Download the desired version of the FIT SDK zip file. We will use ~/dl/FitSDKRelease_16.20.zip as the filepath in this example.

  2. Invoke fitgen with the zip filepath to generate the profile:

     fitgen: root src directory: /home/tormod/src/github.com/tormoder/fit
     fitgen: sdk version: 16.20
     fitgen: parse workbook: done
     fitgen: typegen: success
     fitgen: msggen: Session should call expandComponents() on add in file_types.go
     fitgen: msggen: Lap should call expandComponents() on add in file_types.go
     fitgen: msggen: Record should call expandComponents() on add in file_types.go
     fitgen: msggen: Event should call expandComponents() on add in file_types.go
     fitgen: msggen: success
     fitgen: profilegen: success
     fitgen: stringer: types done
     fitgen: go test: pass
     fitgen: mesgnum-vs-msgs: #mesgnum values: 61
     fitgen: mesgnum-vs-msgs: #generated messages: 59
     fitgen: mesgnum-vs-msgs: #mesgnum values != #generated messages, diff: 2
     fitgen: mesgnum-vs-msgs: remember to verify map in mappings.go for the following message(s):
     fitgen: mesgnum-vs-msgs: ----> mesgnum "Pad" has no corresponding message
     fitgen: mesgnum-vs-msgs: ----> mesgnum "GpsMetadata" has no corresponding message
     fitgen: mesgnum-vs-msgs: this may be automated in the future
     fitgen: done
    
  3. You should now see git listing the following files modified in the fit repository if fitgen exited successfully:

             modified:   messages.go
             modified:   profile.go
             modified:   types.go
             modified:   types_string.go
    

Example 2: Custom profile

  1. Decompress the FIT SDK zip file. We will use ~/dl/FitSDKRelease_16.20/Profile.xlsx as the filepath for profile workbook in this example.

  2. Do the desired changes to the EXAMPLE column in the Messages sheet in the profile workbook. Save the file.

  3. Invoke fitgen with the workbook as input. You can also provide an optional string flag describing your custom profile:

     $ fitgen -sdkVersion MyProfile ~/dtmp/fit/FitSDKRelease_16.20/Profile.xlsx
    
  4. You should see the same files modified as in the example above if fitgen exited successfully.

References

[1] Flexible & Interoperable Data Transfer (FIT) Protocol. http://www.thisisant.com/resources/fit/