Class: Toybox.Ant.CryptoConfig

Inherits:
Toybox.Lang.Object show all

Overview

A class to handle encryption of ANT wireless data.

See Also:

Example:

 using Toybox.Ant;
 // Use a set of constants for configuration
 const ENCRYPTION_ID = 4294967295;             // Define ID
 const ENCRYPTION_KEY = [1, 2, 3, 4, 5, 6];    // Define Key
 const ENCRYPTION_USER_INFO_STRING = [         // String "hello world" in hex
     0x68, 0x65, 0x6c,
     0x6c, 0x6f, 0x20,
     0x77, 0x6f, 0x72,
     0x6c, 0x64
 ];
 const ENCRYPTION_DECIMATION_RATE = 1;         // Define Decimation Rate

 // Define the CryptoConfig
 cryptoConfig = new Ant.CryptoConfig(
     {
     :encryptionID => ENCRYPTION_ID,
     :encryptionKey => ENCRYPTION_KEY,
     :userInfoString => ENCRYPTION_USER_INFO_STRING,
     :decimateRate => ENCRYPTION_DECIMATION_RATE
     }
);

Since:

API Level 2.3.0

Supported Devices:

Constant Summary

Constant Variables

Type Name Value Since Description
Type DEFAULT_ENCRYPTION_ID 0

API Level 2.3.0

Type DEFAULT_USER_INFO_STRING 0

API Level 2.3.0

Type ENCRYPTION_KEY_LENGTH 16

API Level 2.3.0

Type USER_INFO_STRING_LENGTH 19

API Level 2.3.0

Instance Member Summary collapse

Instance Method Summary collapse

Instance Attribute Details

var decimationRate as Lang.Number

The division factor of the encryption counter

Since:

API Level 2.3.0

var encryptionId as Lang.Number

The unique 4 byte identifier of the encrypted master or the negotiating slave.

Since:

API Level 2.3.0

var encryptionKey as Lang.Array<Lang.Number>

The 128-bit encryption key used to encrypt/decrypt ANT packets.

Since:

API Level 2.3.0

var userInfoString as Lang.Array<Lang.Number>

The (optional) user information String to be sent to the master channel on successful negotiation of encryption (Slave channels only).

Since:

API Level 2.3.0

Instance Method Details

initialize(options as { :encryptionId as Lang.Number, :encryptionKey as Lang.Array<Lang.Number>, :userInfoString as Lang.Array<Lang.Number>, :decimationRate as Lang.Number })

Constructor

Parameters:

  • options(Lang.Dictionary)

    The Dictionary of options for the configuration

    • :encryptionId(Lang.Number)

      a Number (uint32) to uniquely identify a device during encryption negotiation

    • :encryptionKey(Lang.Array)

      The key which will be used to encrypt/decrypt ANT packets as an Array of bytes

    • :userInfoString(Lang.Array)

      The string to send during negotiation to the master channel (only used when the channel is configured as a slave) as an Array of bytes

    • :decimationRate(Lang.Number)

      A Number with range 1-255 used for division of the master channel rate by the slave's

Since:

API Level 2.3.0


Generated Sep 25, 2023 12:31:44 PM