Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IDevice

Represents a bluetooth device.

since

1.0.0

Hierarchy

  • IDevice

Implemented by

Index

Properties

Methods

Properties

address

address: string

Address of the device.

id

id: string

Unique identifier for the device.

Methods

connect

  • connect(read?: undefined | string, write?: undefined | string): Promise<IDevice>
  • Connects the device with the bluetooth network. Returns a promise that resolves with the connected device or rejects with an error if the connection could not established.

    Parameters

    • Optional read: undefined | string

      Id of the read characteristic

    • Optional write: undefined | string

      Id of the write characteristic

    Returns Promise<IDevice>

    Connected device

disconnect

  • Disconnects the devilce from the bluetooth network. Returns a promise that resolves the disconnected device or rejects with an error if the disconnection fails.

    Returns Promise<IDevice>

    Disconnected device

read

  • read(listener: function): void
  • Adds a listener to the device that invokes if the device receives any data. The data is represented as a byte buffer.

    Parameters

    • listener: function

      Listener for data events

        • (data: Buffer): any
        • Parameters

          • data: Buffer

            The events data

          Returns any

    Returns void

write

  • write(data: Buffer): Promise<void>
  • Writes data represented as byte buffer to a device. Returns a promise that resolves after the data has been written successfully to the device or returns an error if the write was not successful.

    Parameters

    • data: Buffer

      Data to send as byte Buffer

    Returns Promise<void>

    State of successful write

Generated using TypeDoc