Skip to content

Main API Reference

Tormod Erevik Lea edited this page Nov 6, 2015 · 3 revisions

The main decoding interface is listed below. See godoc for a complete list of FIT types and messages.

func CheckIntegrity

func CheckIntegrity(r io.Reader, headerOnly bool) error

CheckIntegrity verifies the FIT header and file CRC. Only the header CRC is verified if headerOnly is true.

type Fit

type Fit struct {
    // Header is the FIT file header.
    Header Header

    // CRC is the FIT file CRC.
    CRC uint16

    // FileId is a message required for all FIT files.
    FileId FileIdMsg

    // Common messages for all FIT file types.
    FileCreator          *FileCreatorMsg
    TimestampCorrelation *TimestampCorrelationMsg
    DeviceInfo           *DeviceInfoMsg

    // UnknownMessages is a map that maps an unknown message number to how
    // many times the message was encountered during encoding.
    UnknownMessages map[MesgNum]int

    // UnknownFields is a map that maps an unknown field to how many times
    // the field was encountered during encoding.
    UnknownFields map[UnknownField]int
    // contains filtered or unexported fields
}

Fit represents a decoded FIT file.

func Decode

func Decode(r io.Reader) (*Fit, error)

Decode reads a FIT file from r and returns it as a *Fit.

func (*Fit) Activity

func (f *Fit) Activity() (*ActivityFile, error)

Activity returns f's Activity file. An error is returned if the FIT file is not of type activity.

func (*Fit) ActivitySummary

func (f *Fit) ActivitySummary() (*ActivitySummaryFile, error)

ActivitySummary returns f's ActivitySummary file. An error is returned if the FIT file is not of type activity summary.

func (*Fit) BloodPressure

func (f *Fit) BloodPressure() (*BloodPressureFile, error)

BloodPressure returns f's BloodPressure file. An error is returned if the FIT file is not of type blood pressure.

func (*Fit) Course

func (f *Fit) Course() (*CourseFile, error)

Course returns f's Course file. An error is returned if the FIT file is not of type course.

func (*Fit) Device

func (f *Fit) Device() (*DeviceFile, error)

Device returns f's Device file. An error is returned if the FIT file is not of type device.

func (*Fit) FileType

func (f *Fit) FileType() File

FileType returns the FIT file type.

func (*Fit) Goals

func (f *Fit) Goals() (*GoalsFile, error)

Goals returns f's Goals file. An error is returned if the FIT file is not of type goals.

func (*Fit) MonitoringA

func (f *Fit) MonitoringA() (*MonitoringAFile, error)

MonitoringA returns f's MonitoringA file. An error is returned if the FIT file is not of type monitoring A.

func (*Fit) MonitoringB

func (f *Fit) MonitoringB() (*MonitoringBFile, error)

MonitoringB returns f's MonitoringB file. An error is returned if the FIT file is not of type monitoring B.

func (*Fit) MonitoringDaily

func (f *Fit) MonitoringDaily() (*MonitoringDailyFile, error)

MonitoringDaily returns f's MonitoringDaily file. An error is returned if the FIT file is not of type monitoring daily.

func (*Fit) Schedules

func (f *Fit) Schedules() (*SchedulesFile, error)

Schedules returns f's Schedules file. An error is returned if the FIT file is not of type schedules.

func (*Fit) Segment

func (f *Fit) Segment() (*SegmentFile, error)

Segment returns f's Segment file. An error is returned if the FIT file is not of type segment.

func (*Fit) SegmentList

func (f *Fit) SegmentList() (*SegmentListFile, error)

SegmentList returns f's SegmentList file. An error is returned if the FIT file is not of type segment list.

func (*Fit) Settings

func (f *Fit) Settings() (*SettingsFile, error)

Settings returns f's Settings file. An error is returned if the FIT file is not of type settings.

func (*Fit) Sport

func (f *Fit) Sport() (*SportFile, error)

Sport returns f's Sport file. An error is returned if the FIT file is not of type sport.

func (*Fit) Totals

func (f *Fit) Totals() (*TotalsFile, error)

Totals returns f's Totals file. An error is returned if the FIT file is not of type totals.

func (*Fit) Weight

func (f *Fit) Weight() (*WeightFile, error)

Weight returns f's Weight file. An error is returned if the FIT file is not of type weight.

func (*Fit) Workout

func (f *Fit) Workout() (*WorkoutFile, error)

Workout returns f's Workout file. An error is returned if the FIT file is not of type workout.

type Header

type Header struct {
    Size            byte
    ProtocolVersion byte
    ProfileVersion  uint16
    DataSize        uint32
    DataType        [4]byte
    CRC             uint16
}

Header represents a FIT file header.

func DecodeHeader

func DecodeHeader(r io.Reader) (Header, error)

DecodeHeader returns the FIT file header without decoding the entire FIT file.

func DecodeHeaderAndFileID

func DecodeHeaderAndFileID(r io.Reader) (Header, FileIdMsg, error)

DecodeHeaderAndFileID returns the FIT file header and FileId message without decoding the entire FIT file. The FileId message must be present in all FIT files.

func (Header) CheckIntegrity

func (h Header) CheckIntegrity() error

CheckIntegrity verifies the FIT header CRC.

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Header) String

func (h Header) String() string

Generated by godoc2md