Class: Toybox::Ant::ChannelAssignment

Inherits:
Lang::Object show all

Overview

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

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(c, n) ⇒ ChannelAssignment

Constructor for the channel object. By default disables background scanning.

Examples:

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);

Parameters:

  • c (enum)

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

  • n (enum)

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

See Also:

Since:

  • 1.0.0


1210
1211
# File 'Monkeybrains.rb', line 1210

def initialize(c, n)
end

Instance Attribute Details

channelTypeObject

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:

  • 1.0.0


1247
1248
1249
# File 'Monkeybrains.rb', line 1247

def channelType
  @channelType
end

networkObject

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:

  • 1.0.0


1255
1256
1257
# File 'Monkeybrains.rb', line 1255

def network
  @network
end

Instance Method Details

isBackgroundScanEnabledToybox::Lang::Boolean

See if background scanning is enabled for the channel assignment.

Examples:

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

Returns:

Since:

  • 1.2.0


1221
1222
# File 'Monkeybrains.rb', line 1221

def isBackgroundScanEnabled()
end

setBackgroundScan(isBackgroundScanEnabled) ⇒ Toybox::Lang::Boolean

Set background scan to be enabled or disabled.

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

Examples:

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

Parameters:

  • isBackgroundScanEnabled (Toybox::Lang::Boolean)

    Value is true to enable background scan, otherwise false.

Returns:

  • (Toybox::Lang::Boolean)

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

Since:

  • 1.2.0


1236
1237
# File 'Monkeybrains.rb', line 1236

def setBackgroundScan(isBackgroundScanEnabled)
end