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 = [                      // Define Key
    0x00, 0x01, 0x02, 0x03,
    0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b,
    0x0c, 0x0d, 0x0e, 0x0f
];
const ENCRYPTION_USER_INFO_STRING = [         // String "hello world" in hex
    0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
    0x77, 0x6f, 0x72, 0x6c, 0x64, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00
];
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

Typedef Summary collapse

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 CryptoConfig.EncryptionKey

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

Since:

API Level 2.3.0

var userInfoString as CryptoConfig.UserInfoString or Null

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 CryptoConfig.EncryptionKey, :userInfoString as CryptoConfig.UserInfoString, :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 Apr 17, 2024 9:40:36 AM