Class: Toybox::Ant::CryptoConfig

Inherits:
Lang::Object show all

Overview

A class to handle encryption of ANT wireless data.

Examples:

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
    }
);

See Also:

Since:

  • 2.3.0

Constant Summary

DEFAULT_ENCRYPTION_ID = 0

Since:

  • 2.3.0

ENCRYPTION_KEY_LENGTH = 16

Since:

  • 2.3.0

USER_INFO_STRING_LENGTH = 19

Since:

  • 2.3.0

DEFAULT_USER_INFO_STRING = 0

Since:

  • 2.3.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(options) ⇒ CryptoConfig

Returns a new instance of CryptoConfig

Parameters:

Options Hash (options):

  • :encryptionId (Toybox::Lang::Number)

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

  • :encryptionKey (Toybox::Lang::Array)

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

  • :userInfoString (Toybox::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 (Toybox::Lang::Number)

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

Since:

  • 2.3.0


1461
1462
# File 'Monkeybrains.rb', line 1461

def initialize(options)
end

Instance Attribute Details

decimationRateObject

The division factor of the encryption counter

Since:

  • 2.3.0


1445
1446
1447
# File 'Monkeybrains.rb', line 1445

def decimationRate
  @decimationRate
end

encryptionIdObject

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

Since:

  • 2.3.0


1432
1433
1434
# File 'Monkeybrains.rb', line 1432

def encryptionId
  @encryptionId
end

encryptionKeyObject

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

Since:

  • 2.3.0


1436
1437
1438
# File 'Monkeybrains.rb', line 1436

def encryptionKey
  @encryptionKey
end

userInfoStringObject

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

Since:

  • 2.3.0


1441
1442
1443
# File 'Monkeybrains.rb', line 1441

def userInfoString
  @userInfoString
end