Documentation

Mistake on this page? Email us

Represents a single TLV value.

Hierarchy

  • TlvValue

Index

Constructors

constructor

  • Creates a new TlvValue object.

    Parameters

    • info: LwM2MResourceInfo | undefined

      Optional information about the resource.

    • type: TlvValueType

      The type of this TLV node.

    • id: string | number

      The ID of this TLV node.

    • value: any

      The raw unparsed value of this TLV node.

    Returns TlvValue

Properties

dataType

dataType: TlvDataType

Gets the data type of this TLV value.

description

description: string

Gets the description of this TLV value.

hasChildren

hasChildren: boolean

Indicates whether this node is not a leaf and has children. Note that a malformed node may be marked to have children but its value be empty, if you need to determine this then check both for this property and for children.length.

id

id: number

Gets the ID of this TLV value.

name

name: string

Gets the name of this TLV value.

type

Gets the type of this TLV value.

value

value: any

Gets the raw value (as a byte array) of this TLV value.

Accessors

children

children:

Gets an array with all the children of this node.

Methods

asBoolean

  • asBoolean(): boolean
  • Obtains the boolean value of this node. If the stored value does not match then result is indeterminate.

    Returns boolean

asFloat

  • asFloat(): number
  • Obtains the floating point value of this node. If the stored value does not match then result is indeterminate.

    Returns number

asInteger

  • asInteger(): number
  • Obtains the integer value of this node. If the stored value does not match then result is indeterminate.

    Returns number

asString

  • asString(): string
  • Obtains the string value of this node. If the stored value does not match then result is indeterminate.

    Returns string

asTime

  • asTime(): Date
  • Obtains the timestamp value of this node. If the stored value does not match then result is indeterminate.

    Returns Date

findChildById

  • findChildById(...id: Array<string | number>): TlvValue | null
  • Find the first child resource with the specified ID.

    Parameters

    • Rest ...id: Array<string | number>

      The ID of the resource to find, if it is a string then it's first converted to a number. Note that id must be an unsigned 16 bit value. Select children specifying multiple IDs: node.findChildById(1, 2) first searches the node's child with ID 1 and then returns the child of that child with ID 2.

    Returns TlvValue | null

    The resource with the specified id or null if not found.

toJSON

  • toJSON(): object
  • Returns a JSON representation of this node.

    Returns object

toString

  • Returns a string representation of this node and all its children (if any).

    Parameters

    • Default value output: StringBuilder = new StringBuilder()

      The string builder used to construct the output string. You can use this when you need to dump the value of this node together with the output of other nodes.

    • Optional customValueFormatter: TlvCustomValueFormatter

      Custom function to format nodes value. If specified it accepts a first parameter TlvValue, which is the node with the value to format, and a second parameter TlvDataType which is the data type for the node (or the guessed one if type is not available). Return value must be a string.

    Returns string

valueToString

  • valueToString(): string
  • Returns a string representation of the value of this node. If data type is not available then it tries to guess the data type from value content and format.

    Returns string