Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Bluetooth

Bluetooth environment using noble.js.

since

1.0.0

Hierarchy

  • Bluetooth

Implements

Index

Constructors

constructor

  • new Bluetooth(onDiscover?: function, onError?: (Anonymous function), timeout?: number): Bluetooth
  • Creates a instance that represents a the local bluetooth environment.

    Parameters

    • Default value onDiscover: function = () => {}

      Callback if device is discovered

    • Default value onError: (Anonymous function) = () => {}

      Callback if error occurs

    • Default value timeout: number = 500

      Time to wait for connected bluetooth adapter

    Returns Bluetooth

Properties

Private _onDiscover

_onDiscover: function

Type declaration

Private _onError

_onError: function

Type declaration

    • (error: any): any
    • Parameters

      • error: any

      Returns any

Private _retries

_retries: number = 3

Private _state

_state: State = "unknown"

Private _timeout

_timeout: number

Accessors

onDiscover

  • set onDiscover(callback: function): void

onError

  • set onError(callback: function): void
  • Parameters

    • callback: function
        • (error: any): any
        • Parameters

          • error: any

          Returns any

    Returns void

state

timeout

  • get timeout(): number
  • set timeout(timeout: number): void

Methods

Private enableAdapter

  • enableAdapter(): Promise<void>
  • Enables the local bluetooth adapter. Returns promise that resolves, if the adapter is online or rejects if

    Returns Promise<void>

    State if adapter is enabled

startScanning

  • startScanning(serviceUUIDS?: string[]): Promise<void>
  • Starts the discovery process of the bluetooth adapter. executes the onDiscover callback if a new device is detected or executes the onError callback if any errors occurs from the bluetooth device. Returns a promise that resolves after the discovery process is started or rejects if the process can not be started successfully.

    Parameters

    • Optional serviceUUIDS: string[]

    Returns Promise<void>

    State after discovery process

stopScanning

  • stopScanning(): Promise<void>
  • Stops the discovery Process. Returns a promise that resolves after the process is stopped successfully or rejects if the process can not be stopped orderly.

    Returns Promise<void>

    State after stopping the discovery process

Generated using TypeDoc