Google is committed to advancing racial equity for Black communities. See how.

PairingCodeUtils

public class PairingCodeUtils extends Object

Utility functions for working with Nest pairing codes.

Constant Summary

int BITS_PER_CHARACTER Number of bits encoded in a single pairing code character.
int KRYPTONITE_PAIRING_CODE_LENGTH Pairing code length for Kryptonite.
int STANDARD_PAIRING_CODE_LENGTH Pairing code length for most Nest products.

Public Constructor Summary

Public Method Summary

static boolean
isValidPairingCode(String pairingCode)
Verify the syntax and integrity of a Nest pairing code.
static String
kryptoniteDeviceIdToPairingCode(long deviceId)
Returns the pairing code corresponding to a given Kryptonite device ID.
static long
kryptonitePairingCodeToDeviceId(String pairingCode)
Returns the device ID corresponding to a given Kryptonite pairing code.
static String
nevisDeviceIdToPairingCode(long deviceId)
Returns the pairing code corresponding to a given Nevis device ID.
static long
nevisPairingCodeToDeviceId(String pairingCode)
Returns the device ID corresponding to a given Nevis pairing code.
static String
normalizePairingCode(String pairingCode)
Normalize the characters in a pairing code string.

Inherited Method Summary

Constants

public static final int BITS_PER_CHARACTER

Number of bits encoded in a single pairing code character.

Constant Value: 5

public static final int KRYPTONITE_PAIRING_CODE_LENGTH

Pairing code length for Kryptonite.

Constant Value: 9

public static final int STANDARD_PAIRING_CODE_LENGTH

Pairing code length for most Nest products.

Constant Value: 6

Public Constructors

public PairingCodeUtils ()

Public Methods

public static boolean isValidPairingCode (String pairingCode)

Verify the syntax and integrity of a Nest pairing code.

Parameters
pairingCode The pairing code.

public static String kryptoniteDeviceIdToPairingCode (long deviceId)

Returns the pairing code corresponding to a given Kryptonite device ID. If the supplied device id is not a valid Krytponite device id, the method returns null.

Parameters
deviceId The Kryptonite device ID.

public static long kryptonitePairingCodeToDeviceId (String pairingCode)

Returns the device ID corresponding to a given Kryptonite pairing code. If the supplied pairing code is not valid, of is not a Kryptonite pairing code the method returns 0.

Parameters
pairingCode The Kryptonite pairing code.

public static String nevisDeviceIdToPairingCode (long deviceId)

Returns the pairing code corresponding to a given Nevis device ID. If the supplied device id is not a valid Nevis device id, the method returns null.

Parameters
deviceId The Nevis device ID.

public static long nevisPairingCodeToDeviceId (String pairingCode)

Returns the device ID corresponding to a given Nevis pairing code. If the supplied pairing code is not valid, of is not a Nevis pairing code the method returns 0.

Parameters
pairingCode The Nevis pairing code.

public static String normalizePairingCode (String pairingCode)

Normalize the characters in a pairing code string. This function converts all alphabetic characters to upper-case, maps the illegal characters 'I', 'O', 'Q' and 'Z' to '1', '0', '0' and '2', respectively, and removes all other non-pairing code characters from the given string.

Parameters
pairingCode The pairing code.