Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObnizBLE<EventTypes>

Use a obniz device as a BLE device. Peripheral and Central mode are supported

Type parameters

  • EventTypes: string

Hierarchy

Index

Constructors

constructor

Properties

Obniz

Obniz: Obniz

obniz to be used

characteristic

characteristic: typeof BleCharacteristic

descriptor

descriptor: typeof BleDescriptor

hci

peripheral

peripheral: BlePeripheral

scan

scan: BleScan

security

security: BleSecurity

service

service: typeof BleService

timeout

timeout: number = 30 * 1000

Rsponse waiting timeout in milliseconds

Static prefixed

prefixed: string | boolean

Methods

addListener

  • addListener(event: EventTypes, fn: ListenerFn, context?: any): this
  • Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

debugHandler

  • debugHandler(): void
  • Returns void

directConnect

  • Connect to peripheral without scanning. Returns a peripheral instance, but the advertisement information such as localName is null because it has not been scanned.

    // Javascript Example
    
    await obniz.ble.initWait();
    var peripheral = obniz.ble.directConnect("e4b9efb29218","random");
    peripheral.onconnect = ()=>{
      console.log("connected");
    }

    Parameters

    Returns any

directConnectWait

  • Connect to peripheral without scanning, and wait to finish connecting.

    It throws when connection establish failed. Returns a peripheral instance, but the advertisement information such as localName is null because it has not been scanned.

    // Javascript Example
    await obniz.ble.initWait();
    try {
      var peripheral = await obniz.ble.directConnectWait("e4b9efb29218","random");
      console.log("connected");
    } catch(e) {
      console.log("can't connect");
    }

    Parameters

    Returns Promise<any>

emit

  • emit(event: EventTypes, ...args: Array<any>): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: EventTypes
    • Rest ...args: Array<any>

    Returns boolean

eventNames

  • eventNames(): Array<EventTypes>
  • Return an array listing the events for which the emitter has registered listeners.

    Returns Array<EventTypes>

initWait

  • initWait(): Promise<void>
  • Initialize BLE module. You need call this first everything before. This throws if device is not supported device.

    // Javascript Example
    await obniz.ble.initWait();

    Returns Promise<void>

listenerCount

  • listenerCount(event: EventTypes): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: EventTypes

    Returns number

listeners

  • listeners(event: EventTypes): Array<ListenerFn>
  • Return the listeners registered for a given event.

    Parameters

    • event: EventTypes

    Returns Array<ListenerFn>

notifyFromObniz

  • notifyFromObniz(json: any): void

off

  • off(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: undefined | false | true): this
  • Parameters

    • event: EventTypes
    • Optional fn: EventEmitter.ListenerFn
    • Optional context: any
    • Optional once: undefined | false | true

    Returns this

on

  • on(event: EventTypes, fn: ListenerFn, context?: any): this
  • Add a listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

once

  • once(event: EventTypes, fn: ListenerFn, context?: any): this
  • Add a one-time listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

removeAllListeners

  • Remove all listeners, or those of the specified event.

    Parameters

    Returns this

removeListener

  • removeListener(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: undefined | false | true): this
  • Remove the listeners of a given event.

    Parameters

    • event: EventTypes
    • Optional fn: EventEmitter.ListenerFn
    • Optional context: any
    • Optional once: undefined | false | true

    Returns this

schemaBasePath

  • schemaBasePath(): string

validate

  • validate(commandUri: any, json: any): WSSchema.MultiResult
  • Parameters

    • commandUri: any
    • json: any

    Returns WSSchema.MultiResult

Generated using TypeDoc