Class: Toybox::Ant::Message

Inherits:
Lang::Object show all

Overview

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

Examples:

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:

  • 1.0.0

Constant Summary

DATA_PAYLOAD_LENGTH = 8

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Instance Attribute Details

deviceNumberObject

The Unique device number (ANT-id).

Since:

  • 1.2.0


1675
1676
1677
# File 'Monkeybrains.rb', line 1675

def deviceNumber
  @deviceNumber
end

deviceTypeObject

A 1-Byte device type identifier.


1680
1681
1682
# File 'Monkeybrains.rb', line 1680

def deviceType
  @deviceType
end

lengthObject

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

Since:

  • 1.0.0


1667
1668
1669
# File 'Monkeybrains.rb', line 1667

def length
  @length
end

messageIdObject

The Data Type Identifier

Since:

  • 1.0.0


1671
1672
1673
# File 'Monkeybrains.rb', line 1671

def messageId
  @messageId
end

rssiObject

The Received Signal Strength Indication.

Since:

  • 1.0.0


1688
1689
1690
# File 'Monkeybrains.rb', line 1688

def rssi
  @rssi
end

timestampObject

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

Rolls over every 2 seconds.

Since:

  • 1.2.0


1694
1695
1696
# File 'Monkeybrains.rb', line 1694

def timestamp
  @timestamp
end

transmissionTypeObject

The manufacturer-specific transport type and extended device number.

Since:

  • 1.2.0


1684
1685
1686
# File 'Monkeybrains.rb', line 1684

def transmissionType
  @transmissionType
end

Instance Method Details

getPayloadToybox::Lang::Array

Get the ANT data packet.

Returns:

  • (Toybox::Lang::Array)

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

Since:

  • 1.0.0


1700
1701
# File 'Monkeybrains.rb', line 1700

def getPayload()
end

setPayload(data) ⇒ Object

Set the ANT data packet.

Parameters:

  • data (Toybox::Lang::Array)

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

Since:

  • 1.0.0


1707
1708
# File 'Monkeybrains.rb', line 1707

def setPayload(data)
end