Interface Communicator

Interface representing a communication channel with a modem.

The Communicator interface defines the communication methods used by the Modem class to interact with the physical modem device. It abstracts the low-level communication details, allowing the Modem class to focus on higher-level functionality.

interface Communicator {
    connect: (() => Promise<void>);
    deviceIndentifier: string;
    disconnect: (() => Promise<void>);
    isConnected: boolean;
    setOnResiveFunc: ((func) => void);
    write: ((data) => void);
}

Implemented by

Properties

connect: (() => Promise<void>)

Establishes a connection to the communication device. Returns a Promise that resolves when the connection is successfully established.

Type declaration

    • (): Promise<void>
    • Establishes a connection to the communication device. Returns a Promise that resolves when the connection is successfully established.

      Returns Promise<void>

deviceIndentifier: string

Unique identifier for the communication device.

disconnect: (() => Promise<void>)

Disconnects the communicator from the communication device. Returns a Promise that resolves when the disconnection is completed.

Type declaration

    • (): Promise<void>
    • Disconnects the communicator from the communication device. Returns a Promise that resolves when the disconnection is completed.

      Returns Promise<void>

isConnected: boolean

Indicates whether the communicator is currently connected.

setOnResiveFunc: ((func) => void)

Sets a callback function to handle received data.

Type declaration

    • (func): void
    • Sets a callback function to handle received data.

      Parameters

      • func: ((data) => void)

        The function to be called when data is received. It takes a string parameter representing the received data.

          • (data): void
          • Parameters

            • data: string

            Returns void

      Returns void

Param: func

The function to be called when data is received. It takes a string parameter representing the received data.

write: ((data) => void)

Writes data to the communication device.

Type declaration

    • (data): void
    • Writes data to the communication device.

      Parameters

      • data: string

        The data string to be sent through the communicator.

      Returns void

Param: data

The data string to be sent through the communicator.

Generated using TypeDoc