Class: Toybox.Ant.Message

Inherits:
Toybox.Lang.Object show all

Overview

A class to hold and define the information in an ANT wireless data payload.

Example:

using Toybox.Ant;
// Wrap the message prep and broadcast in a callback method
function onMessage(msg) {
    var payload = msg.getPayload(); //get the data payload
    var data = new [msg.length];    // create an array the length of the message

    // Iterate and add data to the Message with each pass
    for (var i = 0; i < msg.length; i++) {
        data[i] = i;            // Adds {0,1,2,3,4,5,6,7}
    }

    var message = new Ant.Message();
    message.setPayload(data);       // Form the Message

    // Set the broadcast buffer
    genericChannel.sendBroadcast(message);
}

Since:

API Level 1.0.0

Constant Summary

Constant Variables

Type Name Value Since Description
Type DATA_PAYLOAD_LENGTH 8

API Level 1.0.0

Instance Member Summary collapse

Instance Method Summary collapse

Instance Attribute Details

var deviceNumber as Lang.Number or Null

The Unique device number (ANT-id).

Since:

API Level 1.2.0

var deviceType as Lang.Number or Null

A 1-Byte device type identifier.

var length as Lang.Number or Null

Number of data bytes in the data payload (not including any extended data if applicable).

Since:

API Level 1.0.0

var messageId as Lang.Number or Null

The Data Type Identifier

Since:

API Level 1.0.0

var rssi as Lang.Number or Null

The Received Signal Strength Indication.

Since:

API Level 1.0.0

var timestamp as Lang.Number or Null

The time stamp of received message generated off of a 32.768 kHz clock.

Rolls over every 2 seconds.

Since:

API Level 1.2.0

var transmissionType as Lang.Number or Null

The manufacturer-specific transport type and extended device number.

Since:

API Level 1.2.0

Instance Method Details

getPayload() as Lang.Array<Lang.Number>

Get the ANT data packet.

Returns:

  • Lang.Array

    An Array of Numbers as integers representing the bytes of the data payload

Since:

API Level 1.0.0

setPayload(data as Lang.Array<Lang.Number>) as Void

Set the ANT data packet.

Parameters:

  • data(Lang.Array)

    An Array of Numbers as integers representing the bytes of the data payload

Since:

API Level 1.0.0


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