Class JDDevice

A Jacdac device hosting services.

Hierarchy

JDOM

bus: JDBus

Gets the bus this device belongs to

eventStats: Record<string, number> = {}

Gets a counter of event emit calls.

newListenerStats: Record<string, number> = undefined

Gets a counter map from events to new listener counts

nodeId: number = ...

Gets an internal unique node identifier, mostly used for debugging.

  • get changeId(): number
  • Gets a counter for the CHANGE event.

    Returns number

  • get friendlyName(): string
  • Gets the device short name

    Returns string

  • get id(): string
  • Gets a unique identifier for this device in the bus

    Returns string

  • get name(): string
  • Gets the short id of the device

    Returns string

  • get nodeData(): Record<string, unknown>
  • Gets a databag to store custom information

    Returns Record<string, unknown>

  • get nodeKind(): string
  • Identifies node as a device

    Returns string

  • get qualifiedName(): string
  • Gets the device short name

    Returns string

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

    Parameters

    • eventName: string
    • Rest ...args: unknown[]

    Returns boolean

  • Emit event in current node and parent nodes

    Parameters

    • event: string

      event to emit

    • Optional arg: any

      event arguments

    Returns void

  • Gets the number of listeners for a given event

    Parameters

    • eventName: string

      name of the event

    Returns number

    number of registered handlers

  • Gets the list stack trace where an event was registered. Only enabled if Flags.debug is true.

    Parameters

    • eventName: string

      name of the event

    Returns string[]

    stack traces where a listener was added

  • Creates an observable from the given event

    Type Parameters

    • T

    Parameters

    • eventName: string | string[]

    Returns Observable<T>

  • Subscribes to an event and returns the unsubscription handler

    Type Parameters

    • T

    Parameters

    • eventName: string | string[]
    • next: ((value) => void)
        • (value): void
        • Parameters

          • value: T

          Returns void

    Returns (() => void)

      • (): void
      • Subscribes to an event and returns the unsubscription handler

        Returns void

        Category

        JDOM

Control

deviceId: string

Gets the device identifier

  • get announceFlags(): ControlAnnounceFlags
  • Gets the control announce flag from the annouce packet.

    Returns ControlAnnounceFlags

  • get firmwareVersion(): string
  • Returns the firmware version synchronously. If needed, tries to refresh the value in the background.

    Returns string

  • get isClient(): boolean
  • Indicates if the device is announced as a client

    Returns boolean

  • get packetCount(): number
  • Gets the number of packets sent since the last announce packet, as read from the announce packet.

    Returns number

  • get productIdentifier(): number
  • Returns the product identifier synchronously. If needed, tries to refresh the value in the background.

    Returns number

  • get restartCounter(): number
  • Gets the restart counter from the announce packet.

    Returns number

  • get statusLight(): LEDController
  • Gets a controller for the status light. Returns undefined if the device does not support a status light.

    Returns LEDController

  • get statusLightFlags(): ControlAnnounceFlags
  • Gets the status light announce flags from the announce packet.

    Returns ControlAnnounceFlags

  • get uptime(): number
  • Gets the elapsed time since boot in milli-seconds

    Returns number

  • Tries to retrive the firmware version from the device

    Parameters

    • retry: number = 0

      number of attempts

    Returns Promise<string>

    promise that returns firmware if received

  • Tries to retrive the product identifier from the device

    Parameters

    • retry: number = 0

      number of attempts

    Returns Promise<number>

    promise that returns product identifier if received

Diagnostics

stats: DeviceStatsMonitor = ...

Quality of service statistics for this device

  • Gets a description of the device.

    Returns string

    a descriptive string for this device

Firmware

  • get firmwareInfo(): FirmwareInfo
  • Gets the firmware information if any.

    Returns FirmwareInfo

Lifecycle

connected: boolean

Indicates if the device is connected to a bus

lastSeen: number

Timestamp of the last packet received from the device

lastServiceUpdate: number

Timestamp of the last service update packet received from the device

  • get announced(): boolean
  • Indicates if service information is available. This happens after a announce packet has been received.

    Returns boolean

  • get eventCounter(): number
  • Gets the number of events received by the service clients in this device

    Returns number

  • get identifying(): boolean
  • Indicates the device should be identifying.

    Returns boolean

  • get lost(): boolean
  • Indicates if no packet from this device has been observed in a while.

    Returns boolean

  • Sends an identify command to the device

    Returns Promise<void>

  • Sends a reset command to the device

    Returns Promise<void>

Other

created: number

Timestamp when the device was first seen

  • get anonymizedDeviceId(): string
  • Gets a random device id for the lifetime of this object.

    Returns string

  • Awaits an event with a timeout. Throws JacdacError with timeout if operation does not return.

    Parameters

    Returns Promise<void>

  • Check if the device is still there

    Returns Promise<boolean>

    true if the device is there, undefined on timeout

  • Send command to enter proxy/dongle mode

    Returns Promise<void>

Services

  • get bootloader(): boolean
  • Indicates if the service is in bootloader mode

    Returns boolean

  • get serviceClasses(): number[]
  • Gets the list of service classes

    Returns number[]

  • get serviceLength(): number
  • Gets the number of services hosted by the device

    Returns number

  • Indicates if the device contains at least one service matching the service class

    Parameters

    • serviceClass: number

      service class to match

    Returns boolean

    true if at least one service present

  • Gets the service client at the given service index

    Parameters

    • serviceIndex: number

      index of the service client

    Returns JDService

    service client

  • Gets the service class at a given index

    Parameters

    • index: number

      index of the service

    Returns number

    service class

Transport

  • get isPhysical(): boolean
  • Indicates if the devices is a physical device, not emulated.

    Returns boolean

  • get replay(): boolean
  • Indicates if the device is part of a trace replay

    Returns boolean

Generated using TypeDoc