Class: Toybox.Ant.ChannelAssignment

Overview

A class to control the assignment of an ANT wireless channel.

Since:

API Level 1.0.0

Instance Member Summary collapse

Instance Method Summary collapse

Instance Attribute Details

var channelType as Ant.ChannelType

Defines the type of channel.

The channel can be defined to primarily send data (master) or receive data(slave). The channel type is set via the CHANNEL_TYPE_* constant passed to the Ant.ChannelAssignment.initialize() function for the channelType parameter.

Since:

API Level 1.0.0

var network as Ant.NetworkType

Defines the type of network the channel should operate under.

The network is set via the NETWORK_* constant passed to the Ant.ChannelAssignment.initialize() function for the network parameter.

Since:

API Level 1.0.0

Instance Method Details

initialize(c as Ant.ChannelType, n as Ant.NetworkType)

Constructor By default disables background scanning.

Parameters:

  • c(Lang.Number)

    The channel type specifier. Must use one of the following constants.

    • CHANNEL_TYPE_TX_NOT_RX - Bidirectional Transmit (Master)

      • Master Channels are not allowed on the ANT+ Network

    • CHANNEL_TYPE_RX_NOT_TX - Bidirectional Receive (Slave)

    • CHANNEL_TYPE_RX_ONLY - Receive Only (Slave)

  • n(Lang.Number)

    The network type specifier. Must use one of the following constants.

    • NETWORK_PUBLIC - ANT public network

    • NETWORK_PLUS - ANT+ network

    • NETWORK_PRIVATE - ANT private network

      • A network key must be provided for an Private Network

      • Both 64 and 128 bit keys are required

Example:

using Toybox.Ant;

var channelType = Ant.CHANNEL_TYPE_RX_NOT_TX  // Bidirectional Receive (Slave)
var network = Ant.NETWORK_PUBLIC;             // Ant public network
// Get the channel
channelAssign = new Ant.ChannelAssignment(channelType, network);

// Initialize the channel - assumes message callback method
GenericChannel.initialize(method(:onMessage), channelAssign);

See Also:

Since:

API Level 1.0.0

isBackgroundScanEnabled() as Lang.Boolean

See if background scanning is enabled for the channel assignment.

Example:

using Toybox.Ant;
// Assuming initialized channel
ChannelAssignment.isBackgroundScanEnabled();

Returns:

  • Lang.Boolean

    Returns true if background scan is enabled, otherwise false.

Since:

API Level 1.2.0

setBackgroundScan(isBackgroundScanEnabled as Lang.Boolean) as Lang.Boolean

Set background scan to be enabled or disabled.

Enabling background scan can only be done on Receive Only channels.

Parameters:

  • isBackgroundScanEnabled(Lang.Boolean)

    Value is true to enable background scan, otherwise false.

Example:

using Toybox.Ant;
// Assuming initialized channel
ChannelAssignment.setBackgroundScan(isBackgroundScanEnabled);

Returns:

  • Lang.Boolean

    Return true if the background scan property was successfully set, otherwise false.

Since:

API Level 1.2.0


Generated Apr 17, 2024 9:40:36 AM