Class: Toybox::Ant::GenericChannel

Inherits:
Lang::Object show all

Overview

A class for controlling an ANT wireless channel.

The GenericChannel provides the methods necessary for initialization, life cycle, and encryption of ANT channels.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(listener, channelAssignment) ⇒ GenericChannel

Constructor for the generic channel.

Examples:

using Toybox.Ant;
// Assumes a listenerCallback method
// and ChannelAssignment object supplied
// as parameters upon initialization
GenericChannel.initialize(method(:listenerCallback), channelAssign);

Parameters:

Raises:

Since:

  • 1.0.0


1487
1488
# File 'Monkeybrains.rb', line 1487

def initialize(listener, channelAssignment)
end

Instance Method Details

closeObject

Close a generic ANT Channel.

Examples:

using Toybox.Ant;
GenericChannel.close();

Since:

  • 1.0.0


1552
1553
# File 'Monkeybrains.rb', line 1552

def close()
end

disableEncryptionObject

Disable encryption on this channel.

Examples:

using Toybox.Ant;
GenericChannel.disableEncryption();

Since:

  • 2.3.0


1534
1535
# File 'Monkeybrains.rb', line 1534

def disableEncryption()
end

enableEncryption(configuration) ⇒ Object

Set the encryption configuration and enable encryption on this channel.

Examples:

using Toybox.Ant;
// Assuming a valid CryptoConfig object is available
var configuration = Ant.CryptoConfig;
GenericChannel.enableEncryption(cryptoConfig);

Parameters:

See Also:

Since:

  • 2.3.0


1526
1527
# File 'Monkeybrains.rb', line 1526

def enableEncryption(configuration)
end

getDeviceConfigToybox::Ant::DeviceConfig

Get the current ANT channel configuration.

Examples:

using Toybox.Ant;
var devConfig = GenericChannel.getDeviceConfig();
// devConfig can now be parsed for configuration info
// from the DeviceConfig object

Returns:

See Also:

Since:

  • 1.0.0


1500
1501
# File 'Monkeybrains.rb', line 1500

def getDeviceConfig()
end

openToybox::Lang::Boolean

Open a generic ANT Channel.

Examples:

using Toybox.Ant;
GenericChannel.open();

Returns:

Since:

  • 1.0.0


1544
1545
# File 'Monkeybrains.rb', line 1544

def open()
end

releaseObject

Release the generic ANT Channel back to the system.

If the channel is open it will be automatically closed.

Examples:

using Toybox.Ant;
GenericChannel.release();

Since:

  • 1.0.0


1562
1563
# File 'Monkeybrains.rb', line 1562

def release()
end

sendAcknowledge(data) ⇒ Object

Send an acknowledge message.

You can expect to receive either MSG_CODE_EVENT_TRANSFER_TX_COMPLETED or MSG_CODE_EVENT_TRANSFER_TX_FAILED if the message succeeded/failed going to the recipient.

Examples:

using Toybox.Ant;
// create a data Array to format Message
var data = new[8];
for (var i = 0; i < 8; i++)
{
    data[i] = i + 1;    // Set the values of each member
}
var message = new Ant.Message;
message.setPayload(data);   // Assumes valid data
GenericChannel.sendAcknowledge(message);

Parameters:

See Also:

Since:

  • 1.0.0


1586
1587
# File 'Monkeybrains.rb', line 1586

def sendAcknowledge(data)
end

sendBroadcast(data) ⇒ Object

Send a broadcast message.

Examples:

using Toybox.Ant;
// create a data Array to format Message
var data = new[8];
for (var i = 0; i < 8; i++)
{
    data[i] = i + 1;    // Set the values of each member
}
var message = new Ant.Message;
message.setPayload(data);   // Assumes valid data
GenericChannel.sendBroadcast(message);

Parameters:

See Also:

Since:

  • 1.0.0


1605
1606
# File 'Monkeybrains.rb', line 1605

def sendBroadcast(data)
end

sendBurst(burstData) ⇒ Object

Send an Array of Messages as a burst across the ANT channel.

Success or Fail is received by the BurstListener.

Examples:

using Toybox.Ant;
var burstData = new Ant.BurstPayload(); // Create new payload

// Message must contain a valid payload
burstData.add(message);                 // Add Message object to payload
GenericChannel.sendBurst(burstData);    // Send Message

Parameters:

See Also:

Since:

  • 2.2.0


1623
1624
# File 'Monkeybrains.rb', line 1623

def sendBurst(burstData)
end

setBurstListener(listener) ⇒ Object

Set the BurstListener for burst events.

Failed bursts or those larger than the specified threshold will be discarded.

Examples:

using Toybox.Ant;
// Assumes a valid BurstListener object as a parameter
GenericChannel.setBurstListener(listener);

Parameters:

See Also:

Since:

  • 2.2.0


1638
1639
# File 'Monkeybrains.rb', line 1638

def setBurstListener(listener)
end

setDeviceConfig(configuration) ⇒ Object

Set the current ANT channel configuration.

Examples:

using Toybox.Ant;
// Assuming a valid DeviceConfig object is available
var configuration = Ant.DeviceConfig;
GenericChannel.setDeviceConfig(configuration);

Parameters:

See Also:

Since:

  • 1.0.0


1513
1514
# File 'Monkeybrains.rb', line 1513

def setDeviceConfig(configuration)
end