Class: Toybox.AntPlus.Device

Inherits:
Toybox.Lang.Object show all

Overview

The Device object represents an ANT+ Device instance.

Since:

API Level 2.2.0

Direct Known Subclasses

AntPlus.BikeCadence, AntPlus.BikePower, AntPlus.BikeRadar, AntPlus.BikeSpeed, AntPlus.BikeSpeedCadence, AntPlus.FitnessEquipment, AntPlus.LightNetwork, AntPlus.RunningDynamics, AntPlus.Shifting

Instance Method Summary collapse

Instance Method Details

getBatteryStatus(identifier as Lang.Number) as AntPlus.BatteryStatus or Null

Retrieve battery status for provided component identifier.

Parameters:

  • identifier(Lang.Number)

    The component identifier to retrieve battery status for

    • null if single-component

    • Light index for bike lights.

Example:

using Toybox.AntPlus;

// Assumes valid component identifier enum value (for bike lights)
// or null for a single component device

var batteryStatus = AntPlus.getBatteryStatus(null);  // Get the batteryStatus Enum value
                                                     // for a single component system.
if (batteryStatus == AntPlus.BATT_STATUS_OK) {
    System.println("Battery Status: Okay!");
} else {
    // display another battery status message
}

Returns:

  • AntPlus.BatteryStatus

    The current battery status for this identifier, or null if unknown identifier

Since:

API Level 2.2.0

getComponentIdentifiers() as Lang.Array<Lang.Number> or Null

Retrieve a list of known component identifiers for this Device.

This list may update over time as ANT+ devices with >1 component periodically send information about each of their components. The device reports its total number of components in CommonData.numComponents. The returned Array will only contain entries for components that the ANT+ device has provided a component identifier for.

Example:

using Toybox.AntPlus;

// Get the list of known components as an Array
var componentList = AntPlus.getComponentIdentifiers();

Returns:

  • Lang.Array

    A list of known component identifiers

    • null if there are no known component identifiers

Since:

API Level 2.2.0

getDeviceState() as AntPlus.DeviceState

Retrieve the state of the device.

Example:

using Toybox.AntPlus;

// Get the DEVICE_STATE_* enum value
var deviceState = AntPlus.getDeviceState(null);

Returns:

Since:

API Level 2.2.0

getManufacturerInfo(identifier as Lang.Number) as AntPlus.ManufacturerInfo or Null

Retrieve manufacturer information for provided component identifier.

Parameters:

  • identifier(Lang.Number)

    The component identifier to retrieve manufacturer information for

    • null if single-component

    • Light index for bike lights

Example:

using Toybox.AntPlus;

// Get the ManufacturerInfo object
var manufacturerInfo = AntPlus.getManufacturerInfo(null);

Returns:

Since:

API Level 2.2.0

getProductInfo(identifier as Lang.Number) as AntPlus.ProductInfo or Null

Retrieve product information for provided component identifier.

Parameters:

  • identifier(Lang.Number)

    The component identifier to retrieve product information for

    • null if single-component

    • Light index for bike lights

Example:

using Toybox.AntPlus;

// Get the ProductInfo object
var productInfo = AntPlus.getProductInfo(null);

Returns:

  • AntPlus.ProductInfo

    The current product information for this identifier

    • null if unknown identifier

Since:

API Level 2.2.0

sendManufacturerMessage(message as Ant.Message) as Void

Send Manufacturer Message

Parameters:

  • message(Ant.Message)

    The Ant message to send. Only exploration (0xE0-0xEF) and manufacturer specific (0xF0-0xFF) pages are allowed. It is recommended to contact the ANT+ group when exploration pages are used at thisisant.com. The onSentMessage() will be called to indicate sent manufacturer message status.

See Also:

Since:

API Level 3.1.0

Throws:

sendPageRequest(pageNumber as Lang.Number) as Void

Send Page request Request 2 broadcast pages from connected sensor. Use onMessage() to process requested page broadcasts from the sensor.

Parameters:

  • pageNumber(Lang.Number)

    The requested page number. Requesting the ANTFS page (0x43) isn't allowed. Page request can change the page rotation of the sensor so they will not be allowed to be sent too frequently. Sending page requests is limited to once every 2 seconds.

Since:

API Level 3.1.0

Throws:


Generated Dec 11, 2024, 8:58:42 AM