Java Garmin/ANT FIT file reader

The ANT ‘Flexibile & Interoperatble Data Transfer’ (FIT) protocol

ANT devices and Garmin GPS units, like the Edge 810 and 830 I use, store all device information in .FIT files. This format is defined in the FIT SDK. It is a binary protocol, not human readable, designed for embedded devices (having limited resources).

Since I wanted to decode the activity files, containing the GPS track, I decided to write a FIT file reader.

The Reader

Usage

The .FIT reader is delivered as Github repository. The project results in a JAR file with all dependencies, together with Javadocs. The FitReader class is the entry point. The readFile() method does the job. It returns a FitMessageRepository instance, containing the FitMessages read. Each Fit Message contains a number of fields. Fit Messages Fields come in two types:

  • Message Fields predefined in Global Profile (see FIT SDK; FitMessageFields).
  • Developer defined message Fields. These are defined in the FIT file itself.

Field values of each message are provided in data records, which can be obtained by the FitMessage class.

Refer to the javadocs, Github repository the FitReader source code and tests, for some example code.

FitReader design

The Global Profile is enclosed in an Excel file in the FIT SDK. It appears that in Garmin (and probably other) devices a lot of FIT fields and messages are used that are not defined in the Global Profile. Therefore, in this FIT reader project this Excel file is extended with two more tabs that contain additional field definitions obtained by reverse engineering.

Known issues

The datatype unsinged long is not supported

Garmin Track Converter

The ‘proof of the pudding’ for the FitReader is the Garmin Track Converter which I wrote to convert tracks logged with my Garmin Edge 880 bike computer. The converter takes in the .FIT files and converts the tracks to .GPX format, to be used in other programs.

Waypoints that can be indicated by the user are not stored in the track .FIT. Up to 100 waypoints can be stored in a separate file, Locations.fit. The converter takes this file into account and selects the waypoints that were logged during the track. These selected waypoints <wpt> are combined with the track data <trk> in the GPX file.

The name and serial number of the device is stored in the description of the track.

Download

  • TBD

Source code

Available on GitHub:

FitReader

Garmin Track Converter