-
Notifications
You must be signed in to change notification settings - Fork 42
Custom Product Profiles
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.
This sections explains how to generate a custom FIT profile.
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.
If you want to make no changes to the profile (e.g. just updating to a newer SDK version), generating a profile is simple:
-
Download the desired version of the FIT SDK zip file. We will use
~/dl/FitSDKRelease_16.20.zip
as the filepath in this example. -
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
-
You should now see git listing the following files modified in the
fit
repository iffitgen
exited successfully:modified: messages.go modified: profile.go modified: types.go modified: types_string.go
-
Decompress the FIT SDK zip file. We will use
~/dl/FitSDKRelease_16.20/Profile.xlsx
as the filepath for profile workbook in this example. -
Do the desired changes to the
EXAMPLE
column in theMessages
sheet in the profile workbook. Save the file. -
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
-
You should see the same files modified as in the example above if
fitgen
exited successfully.
[1] Flexible & Interoperable Data Transfer (FIT) Protocol. http://www.thisisant.com/resources/fit/