Utility functions

SCWS.ICAO.getFileIdentifier(dataGroupId)

Utility function that returns an elementary File Identifier (FID) from a Data Group tag or number. Given dataGroupId parameter can have several forms:

  • an object with a tag attribute as an integer, corresponding to the ASN.1 DER TAG of Data Group.

  • an integer representing the ASN.1 DER TAG of Data Group, as used in EF.COM file content.

  • an integer between 1 and 16, representing a Data Group number as used in EF.SOD file content.

Arguments
  • dataGroupId – The Data Group tag or number.

Returns

The FID as an integer or null if given Data Group tag or number is unknown.

Examples:

// DG 1:
//   - tag: 0x61
//   - FID: 0x0101 (257 decimal value)

// get DG FID by explicit tag
var objectWithTag = {tag: 0x61};
SCWS.ICAO.getFileIdentifier(objectWithTag);
>> 257

// get DG FID by tag
SCWS.ICAO.getFileIdentifier(0x61);
>> 257

// get DG FID by DG number
SCWS.ICAO.getFileIdentifier(1);
>> 257

Some utility functions are provided to perform conversions between data representations.

SCWS.toHexString(buffer)

Utility function that converts an ArrayBuffer or a Uint8Array to a hexadecimal string.

Arguments
  • buffer – The ArrayBuffer or Uint8Array input value.

Returns

The hexadecimal string.

SCWS.fromHexString(hex)

Utility function that converts a hexadecimal string to an ArrayBuffer.

Arguments
  • hex – The hexadecimal string input.

Returns

The ArrayBuffer value.