Class: Toybox.ActivityRecording.Session

Overview

Session objects control the FIT recording state machine.

Example:

Format for setting up a Session object

using Toybox.ActivityRecording;
var session = ActivityRecording.createSession({  // set up recording session
    :name=>"Generic",                            // set session name
    :sport=>Activity.SPORT_GENERIC,              // set sport type
    :subSport=>Activity.SUB_SPORT_GENERIC        // set sub sport type
});

Since:

API Level 1.0.0

Instance Method Summary collapse

Instance Method Details

addLap() as Lang.Boolean

Add a lap to the current recording.

Returns:

  • Lang.Boolean

    true if a lap was successfully created, otherwise false

Since:

API Level 1.0.0

createField(name as Lang.String, fieldId as Lang.Number, type as FitContributor.DataType, options as { :count as Lang.Number, :mesgType as Lang.Number, :units as Lang.String, :nativeNum as Lang.Number }) as FitContributor.Field

Create a new Field.

Field objects allow developers to store information in FIT developer fields. This information can be displayed in Garmin Connect as a per-second graph, as lap information, or as workout summary information.

Parameters:

  • name(Lang.String)

    The name of the Field as a String

    • The maximum length may vary between products

    • At least 64 bytes are available

  • fieldId(Lang.Number)

    The unique Field Identifier for the Field

  • type(FitContributor.DataType)

    The type definition for the Field from the DATA_TYPE_* enumerator in the FitContributor module

  • options(Lang.Dictionary)

    Optional parameters that can be specified for Field creation

    • :count(Lang.Number)

      The number of elements to add to the Field if it is an Array

      • This is also the maximum combined size of strings plus null terminators if the type is DATA_TYPE_STRING (Default 1)

      • Apps are limited to 256 total bytes per message

      • Data fields are limited to 32 bytes per message

      • Messages larger than the limit will result in a "New Field out of memory for FIT data" error.

    • :mesgType(Lang.Number)

      The message type that this Field should be added to

      • Defaults to MESG_TYPE_RECORD if not provided

      • If mesgType == MESG_TYPE_RECORD, DATA_TYPE_STRING cannot be used as the Field type.

    • :units(Lang.String)

      The display units as a String

      • This should use the current device language

      • The maximum length may vary between products

      • At least 16 bytes are available

    • :nativeNum(Lang.Number)

      If this Field can be treated equivalently to a Field that is included in the FIT SDK use this to indicate the Field Number that is specified by the FIT Profile.

Returns:

See Also:

Since:

API Level 1.3.0

discard() as Lang.Boolean

Complete the Session by discarding the recorded data.

Returns:

  • Lang.Boolean

    true if the Session was successfully discarded, otherwise false

Since:

API Level 1.0.0

isRecording() as Lang.Boolean

Check if recording is active for this Session.

Returns:

  • Lang.Boolean

    true if recording is active, otherwise false

Since:

API Level 1.0.0

save() as Lang.Boolean

Complete the session by storing the FIT file on the file system.

Returns:

  • Lang.Boolean

    true if the session was successfully saved, otherwise false

Since:

API Level 1.0.0

setTimerEventListener(listener as Lang.Method(eventType as ActivityRecording.TimerEventType, eventData as Lang.Dictionary) as Void) as Void

Set the listener for Session timer events

The listener method is called whenever a new timer event occurs.

The keys in the Dictionary passed to the listener callback depend on the the value of the eventType parameter.

Parameters:

  • listener(Lang.Method)

    A reference to a callback which must accept two arguments.

    • eventType: A TIMER_EVENT_* enum that describes the event that occurred.

    • eventData: A Dictionary containing data relevant to the timer event or null. If eventType is TIMER_EVENT_LAP, the following are provided if available:

      • :elapsedDistance Float (meters)

      • :averageSpeed Float (meters/second)

      • :maxSpeed Float (meters/second)

      • :startTime Moment (Moment)

      • :elapsedTime Number (milliseconds)

      • :timerTime Number (milliseconds)

Supported Devices:

Since:

API Level 3.0.10

start() as Lang.Boolean

Begin recording a FIT file on the system.

Returns:

  • Lang.Boolean

    true if recording was successfully started, otherwise false

Since:

API Level 1.0.0

stop() as Lang.Boolean

Stop recording a FIT file on the system.

Returns:

  • Lang.Boolean

    true if recording was successfully stopped, otherwise false

Since:

API Level 1.0.0


Generated Jun 6, 2024 10:31:52 AM