Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new Adapter(modblue: MODblue, id: string, name: string, address?: string): Adapter

Properties

Readonly id

id: string

The unique identifier of this adapter.

Readonly modblue

modblue: MODblue

The instance of MODblue that this adapter was found by.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

address

  • get address(): string
  • The MAC address of this adapter. All lowercase, with colon separator between bytes, e.g. 11:22:33:aa:bb:cc

    Returns string

addressType

  • get addressType(): string

name

  • get name(): string

Methods

addListener

  • Type parameters

    Parameters

    Returns Adapter

emit

  • emit<U>(event: U, ...args: Parameters<AdapterEvents[U]>): boolean
  • Type parameters

    Parameters

    Returns boolean

eventNames

  • eventNames<U>(): U[]
  • Type parameters

    Returns U[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

Abstract getScannedPeripherals

Abstract isAdvertising

  • isAdvertising(): boolean

Abstract isScanning

  • isScanning(): boolean

listenerCount

  • Parameters

    Returns number

listeners

  • Type parameters

    Parameters

    • type: U

    Returns AdapterEvents[U][]

off

  • Type parameters

    Parameters

    Returns Adapter

on

  • Type parameters

    Parameters

    Returns Adapter

once

  • Type parameters

    Parameters

    Returns Adapter

prependListener

  • Type parameters

    Parameters

    Returns Adapter

prependOnceListener

  • Type parameters

    Parameters

    Returns Adapter

rawListeners

  • Type parameters

    Parameters

    • type: U

    Returns AdapterEvents[U][]

removeAllListeners

  • Parameters

    Returns Adapter

removeListener

  • Type parameters

    Parameters

    Returns Adapter

scanFor

  • scanFor(filter: string | ((peripheral: Peripheral) => boolean), timeoutInSeconds?: number, serviceUUIDs?: string[]): Promise<Peripheral>
  • Scans for a specific Peripheral using the specified matching function and returns the peripheral once found. If the timeout is reached before finding a peripheral the returned promise will be rejected.

    Parameters

    • filter: string | ((peripheral: Peripheral) => boolean)

      Either a string that is used as name prefix, or a function that returns true if the specified peripheral is the peripheral we're looking for.

    • timeoutInSeconds: number = 10

      The timeout in seconds. The returned promise will reject once the timeout is reached.

    • Optional serviceUUIDs: string[]

      The UUIDs of the GattServices that must be contained in the advertisement data.

    Returns Promise<Peripheral>

setMaxListeners

  • setMaxListeners(n: number): Adapter
  • Parameters

    • n: number

    Returns Adapter

Abstract setupGatt

  • setupGatt(maxMtu?: number): Promise<GattLocal>
  • Setup the GATT server for this adapter to communicate with connecting remote peripherals.

    Parameters

    • Optional maxMtu: number

      The maximum MTU that will be negotiated in case the remote peripheral starts an MTU negotation.

    Returns Promise<GattLocal>

Abstract startAdvertising

  • startAdvertising(deviceName: string, serviceUUIDs?: string[]): Promise<void>
  • Start advertising on this adapter.

    Parameters

    • deviceName: string

      The device name that is included in the advertisement.

    • Optional serviceUUIDs: string[]

      The UUIDs of the GattServices that are included in the advertisement.

    Returns Promise<void>

Abstract startScanning

  • startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean): Promise<void>
  • Start scanning for nearby Peripherals.

    Parameters

    • Optional serviceUUIDs: string[]

      The UUIDs of the GattService that an advertising packet must advertise to emit a discover event.

    • Optional allowDuplicates: boolean

      True if advertisements for the same peripheral should emit multiple discover events.

    Returns Promise<void>

Abstract stopAdvertising

  • stopAdvertising(): Promise<void>

Abstract stopScanning

  • stopScanning(): Promise<void>

toJSON

  • toJSON(): Record<string, unknown>

toString

  • toString(): string

Generated using TypeDoc