Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Obniz

obniz class is the abstract version of obniz Board hardware within JavaScript. types

By providing obniz id and instantiating it, you can control obniz Board and the connected parts without the details of websocket api.

obnizOS version and obniz.js version

obniz cloud compare your obniz.js version and target device obnizOS version. If your js sdk major number is below from OS version (eg obniz.js is 2.0.0 and obnizOS is 3.0.0) then obniz cloud will alert when connection established. It will work somehow but some functions looses compatibility.

one device from two program

obniz cloud accept multiple websocket connection from multiple obniz.js at same time. every commands from obniz.js will passed to a device and every command from a device will be dispatched to every obniz.js connected to the cloud.

But If one of obniz.js established a connection to a device, then target device will send datas only via local connect. So other connected obniz.js only can send datas and never receive datas from a device.

If you'd like to receive, you need to specify local_connect: false at all of obniz.js to disable local connect.

Hierarchy

Index

Type aliases

Constructors

Embeds Properties

Measurement Properties

Other Properties

Peripherals Properties

network Properties

plugin Properties

Accessors

Methods

Type aliases

Static AnimationStatus

AnimationStatus: _AnimationStatus

Static BitType

BitType: _BitType

Static BleAdvertisement

BleAdvertisement: _BleAdvertisement

Static BleAdvertisementBuilder

BleAdvertisementBuilder: _BleAdvertisementBuilder

Static BleAdvertisementData

BleAdvertisementData: _BleAdvertisementData

Static BleAdvertisementFlag

BleAdvertisementFlag: _BleAdvertisementFlag

Static BleAttributePropery

BleAttributePropery: _BleAttributePropery

Static BleBinary

BleBinary: _BleBinary

Static BleCharacteristic

BleCharacteristic: _BleCharacteristic

Static BleCharacteristicDefine

BleCharacteristicDefine: _BleCharacteristicDefine

Static BleConnectSetting

BleConnectSetting: _BleConnectSetting

Static BleConnectionState

BleConnectionState: _BleConnectionState

Static BleConnectionUpdateParam

BleConnectionUpdateParam: _BleConnectionUpdateParam

Static BleDescriptorDefine

BleDescriptorDefine: _BleDescriptorDefine

Static BleDeviceAddress

BleDeviceAddress: _BleDeviceAddress

Static BleDeviceAddressType

BleDeviceAddressType: _BleDeviceAddressType

Static BleDeviceType

BleDeviceType: _BleDeviceType

Static BleEventType

BleEventType: _BleEventType

Static BlePairingOptions

BlePairingOptions: _BlePairingOptions

Static BlePeripheral

BlePeripheral: _BlePeripheral

Static BlePeripheralDefine

BlePeripheralDefine: _BlePeripheralDefine

Static BleRemoteCharacteristic

BleRemoteCharacteristic: _BleRemoteCharacteristic

Static BleRemoteDescriptor

BleRemoteDescriptor: _BleRemoteDescriptor

Static BleRemotePeripheral

BleRemotePeripheral: _BleRemotePeripheral

Static BleRemoteService

BleRemoteService: _BleRemoteService

Static BleScan

BleScan: _BleScan

Static BleScanAdvertisementFilterParam

BleScanAdvertisementFilterParam: _BleScanAdvertisementFilterParam

Static BleScanMode

BleScanMode: _BleScanMode

Static BleScanResponseData

BleScanResponseData: _BleScanResponseData

Static BleScanSetting

BleScanSetting: _BleScanSetting

Static BleScanTarget

BleScanTarget: _BleScanTarget

Static BleService

BleService: _BleService

Static BleServiceDefine

BleServiceDefine: _BleServiceDefine

Static Directive

Directive: _Directive

Static DirectiveAnimationFrame

DirectiveAnimationFrame: _DirectiveAnimationFrame

Static Display

Display: _Display

Static DriveType

DriveType: _DriveType

Static FlowControlType

FlowControlType: _FlowControlType

Static GrovePinOption

GrovePinOption: _GrovePinOption

Static Handle

Handle: _Handle

Static IBeacon

IBeacon: _IBeacon

Static LogicAnalyzer

LogicAnalyzer: _LogicAnalyzer

Static LogicAnalyzerOptions

LogicAnalyzerOptions: _LogicAnalyzerOptions

Static LogicAnalyzerOptionsExt

LogicAnalyzerOptionsExt: _LogicAnalyzerOptionsExt

Static ObnizApi

ObnizApi: _ObnizApi

Static ObnizApp

ObnizApp: _ObnizApp

Static ObnizBLE

ObnizBLE: _ObnizBLE

Static ObnizBLEHci

ObnizBLEHci: _ObnizBLEHci

Static ObnizBleAttError

ObnizBleAttError: _ObnizBleAttError

Static ObnizBleHciStateError

ObnizBleHciStateError: _ObnizBleHciStateError

Static ObnizBleOpError

ObnizBleOpError: _ObnizBleOpError

Static ObnizBlePairingRejectByRemoteError

ObnizBlePairingRejectByRemoteError: _ObnizBlePairingRejectByRemoteError

Static ObnizBleScanStartError

ObnizBleScanStartError: _ObnizBleScanStartError

Static ObnizBleUnSupportedOSVersionError

ObnizBleUnSupportedOSVersionError: _ObnizBleUnSupportedOSVersionError

Static ObnizBleUnknownCharacteristicError

ObnizBleUnknownCharacteristicError: _ObnizBleUnknownCharacteristicError

Static ObnizBleUnknownDescriptorError

ObnizBleUnknownDescriptorError: _ObnizBleUnknownDescriptorError

Static ObnizBleUnknownPeripheralError

ObnizBleUnknownPeripheralError: _ObnizBleUnknownPeripheralError

Static ObnizBleUnknownServiceError

ObnizBleUnknownServiceError: _ObnizBleUnknownServiceError

Static ObnizBleUnsupportedHciError

ObnizBleUnsupportedHciError: _ObnizBleUnsupportedHciError

Static ObnizBoard

ObnizBoard: _ObnizBoard

Static ObnizDeprecatedFunctionError

ObnizDeprecatedFunctionError: _ObnizDeprecatedFunctionError

Static ObnizError

ObnizError: _ObnizError

Static ObnizI2cError

ObnizI2cError: _ObnizI2cError

Static ObnizI2cWarning

ObnizI2cWarning: _ObnizI2cWarning

Static ObnizMeasure

ObnizMeasure: _ObnizMeasure

Static ObnizMeasureOptions

ObnizMeasureOptions: _ObnizMeasureOptions

Static ObnizMeasureResult

ObnizMeasureResult: _ObnizMeasureResult

Static ObnizOfflineError

ObnizOfflineError: _ObnizOfflineError

Static ObnizParameterError

ObnizParameterError: _ObnizParameterError

Static ObnizPartsInfo

ObnizPartsInfo: _ObnizPartsInfo

Static ObnizPartsInterface

ObnizPartsInterface: _ObnizPartsInterface

Static ObnizSwitch

ObnizSwitch: _ObnizSwitch

Static ObnizTimeoutError

ObnizTimeoutError: _ObnizTimeoutError

Static ObnizUtil

ObnizUtil: _ObnizUtil

Static PWMInterface

PWMInterface: _PWMInterface

Static PWMModulateType

PWMModulateType: _PWMModulateType

Static ParityType

ParityType: _ParityType

Static Parts

Parts<K>: PartsList[K]["instance"]

Type parameters

Static PartsClass

PartsClass<K>: PartsList[K]["class"]

Type parameters

Static PartsOptions

PartsOptions<K>: PartsList[K]["options"]

Type parameters

Static PeripheralAD

PeripheralAD: _PeripheralAD

Static PeripheralGrove

PeripheralGrove: _PeripheralGrove

Static PeripheralGroveParams

PeripheralGroveParams: _PeripheralGroveParams

Static PeripheralGroveType

PeripheralGroveType: _PeripheralGroveType

Static PeripheralI2C

PeripheralI2C: _PeripheralI2C

Static PeripheralIO

PeripheralIO: _PeripheralIO

Static PeripheralPWM

PeripheralPWM: _PeripheralPWM

Static PeripheralSPI

PeripheralSPI: _PeripheralSPI

Static PeripheralUART

PeripheralUART: _PeripheralUART

Static PeripheralUARTOptions

PeripheralUARTOptions: _PeripheralUARTOptions

Static Plugin

Plugin: _Plugin

Static PullType

PullType: _PullType

Static StopBitType

StopBitType: _StopBitType

Static Tcp

Tcp: _Tcp

Static UUID

UUID: _UUID

Static WiFi

WiFi: _WiFi

Constructors

constructor

  • We will now instantiate obniz.

    obniz id is a string. Hyphen '-' is optional, but with just the numbers they can't be accepted.

    new Obniz('1234-5678') // OK
    new Obniz('12345678') // OK
    new Obniz(12345678) // Can't accept

    If you connect to obniz which has an access token, provide an option like this

    new Obniz('1234-5678', {access_token: 'your token here'})

    If obniz id is incorrect, connection will never be established. In nodejs, an error occurs. In HTML, obniz.js shows a prompt message. The user can put in a correct obniz id into it. It shows up only when the format is invalid. If you specify obniz id which doesn't exist, this would never be shown.

    When id is correct, obniz.js will try to connect cloud api and onconnect will be called after connection is established.

    When obniz Board and the device running obniz.js is expected to be in the same network, obniz.js will try to establish a direct Websocket connection to obniz Board. This is called "local connect". When local connect is avaiable, obniz Board can be controlled with almost all commands without having to go through the cloud. However, the connection to the cloud never gets disconnected even when using local connect. But when cloud connection gets closed, the local connect also gets closed.

    The timing onconnect() gets called depends on the availability of local connect. obniz.js will wait a little to establish connection via local connect as much as possible. See the flow below.

    The second parameter when instantiating obniz Board is an option.

    Parameters

    Returns Obniz

Embeds Properties

Optional ble

ble: ObnizHciBLE

If obnizOS ver >= 3.0.0, automatically load ObnizHciBLE, and obnizOS ver < 3.0.0 throw unsupported Error,

Optional display

display: Display

Optional switch

switch: ObnizSwitch

Measurement Properties

Optional logicAnalyzer

logicAnalyzer: LogicAnalyzer

Optional measure

measure: ObnizMeasure

Other Properties

Optional connected_network

connected_network: ConnectedNetwork

Target obniz device's connected network information. This could be changed when obniz device connect another netowrk.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
  console.log(obniz.connected_network.online_at) // online since in unix time.
}

connectionState

connectionState: "closed" | "connecting" | "connected" | "closing"

This let you know connection state to your obniz Board as string value.

  • 'closed' : not connected.
  • 'connecting' : connecting
  • 'connected' : connection established
  • 'closing' : closing connection.
var obniz = new Obniz('1234-5678');
console.log(obniz.connectionState) // => === "connecting"
obniz.onconnect = async function() {
 console.log(obniz.connectionState) // => === "connected"
}

debugprint

debugprint: boolean

This lets obniz.js to show logs like communicated jsons and connection logs in console.log.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
 obniz.io0.output(true);
}

Optional firmware_ver

firmware_ver: undefined | string

This variable indicate installed firmware version of target device

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
  console.log(obniz.firmware_ver) // ex. "2.0.0"
}

Optional hw

hw: undefined | string

This variable indicate connected hardware identifier of target device

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
  console.log(obniz.hw) // ex. "obnizb1"
}

id

id: string

obniz id

isNode

isNode: boolean

Is node.js environment or not.

readonly

Optional metadata

metadata: undefined | {}

Device metadata set on obniz cloud.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
  console.log(obniz.metadata.description) // value for "description"
}

Optional onclose

onclose: undefined | ((obniz: this) => void)

onclose will be called when disconnected.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {

}
obniz.onclose = async function() {

}

Optional onconnect

onconnect: undefined | ((obniz: this) => void)

Once connection is established, onconnect function will be called.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {

}

Operations like turning on/off an io becomes possible only after connection is established, so any operations you want obniz Board to undertake must be written in onconnect

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
  obniz.io0.output(true);
}

Optional onerror

onerror: undefined | ((obniz: this, error: Error) => void)

If an error occurs, the onerror function is called.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {

}
obniz.onerror = async function(ob, error) {
   console.error(error);
}

Optional onloop

onloop: undefined | ((obniz: this) => void | Promise<void>)

Called continuously while obniz device is online. Put your main code inside of onloop and put your setup code inside of onconnect.

onloop will be called after onconnect called. If your funciton set to onconnect return promise, onloop wait until done promise. Even onconnect throws an error onloop will start.

onloop call pingWait() every time to keep connection data buffer between device to your software clean.

var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {

}
obniz.onloop = async function() {

}

onmessage

onmessage: any

Receive message. If you want to send message, see Obniz.message

// Example
obniz.onconnect = function() {
  var motor = obniz.wired("ServoMotor", {gnd:0, vcc:1, signal:2});

  motor.angle(0);
  obniz.onmessage = function(message, from) {
    if (message === "pressed") {
      motor.angle(85);
    }
  };
}

Static M5StackBasic

M5StackBasic: _M5StackBasic = _M5StackBasic

Static M5StickC

M5StickC: _M5StickC = _M5StickC

M5StickC device

Static prefixed

prefixed: string | boolean

Peripherals Properties

Optional ad0

Optional ad1

Optional ad10

Optional ad11

Optional ad2

Optional ad3

Optional ad4

Optional ad5

Optional ad6

Optional ad7

Optional ad8

Optional ad9

Optional i2c0

Optional io

io: PeripheralDirective

Optional io0

Optional io1

Optional io10

Optional io11

Optional io2

Optional io3

Optional io4

Optional io5

Optional io6

Optional io7

Optional io8

Optional io9

Optional pwm0

Optional pwm1

Optional pwm2

Optional pwm3

Optional pwm4

Optional pwm5

Optional spi0

Optional spi1

Optional uart0

Optional uart1

network Properties

Optional wifi

wifi: WiFi

plugin Properties

Optional plugin

plugin: Plugin

Accessors

autoConnect

  • get autoConnect(): boolean
  • set autoConnect(val: boolean): void

Static App

  • App Support class

    Returns ObnizApp

Static api

  • obniz REST api class

    Returns ObnizApi

Static version

  • get version(): any
  • obniz.js version

    Returns any

Methods

_stopPingLoopInBackground

  • _stopPingLoopInBackground(): void

addListener

close

  • close(): void
  • This closes the current connection. You need to set auto_connect to false. Otherwise the connection will be recovered.

    var obniz = new Obniz('1234-5678', {
      auto_connect: false,
      reset_obniz_on_ws_disconnection: false
    });
    
    obniz.connect();
    obniz.onconnect = async function() {
      obniz.io0.output(true);
      obniz.close();
    }
    deprecated

    replace with closeWait

    Returns void

closeWait

  • closeWait(): Promise<void>
  • This closes the current connection. You need to set auto_connect to false. Otherwise the connection will be recovered.

    var obniz = new Obniz('1234-5678', {
      auto_connect: false,
      reset_obniz_on_ws_disconnection: false
    });
    
    obniz.connect();
    obniz.onconnect = async function() {
      obniz.io0.output(true);
      await obniz.closeWait();
    }

    Returns Promise<void>

connect

  • connect(): void
  • You can connect to obniz Board manually by calling connect() when auto_connect is set to be false.

    var obniz = new Obniz('1234-5678', { auto_connect: false });
    
    obniz.connect();
    obniz.onconnect = async function() {
     obniz.io0.output(true);
    }

    Returns void

connectWait

  • connectWait(option?: undefined | { timeout?: undefined | number }): Promise<boolean>
  • With this you wait until the connection to obniz Board succeeds.

    var obniz = new Obniz('1234-5678');
    
    await obniz.connectWait();
    
    obniz.io0.output(true);
    await obniz.closeWait();
    
    • with timeout
    var obniz = new Obniz('1234-5678');
    
    await obniz.connectWait({timeout:10});  //timeout 10sec
    
    if(connected){
       obniz.io0.output(true);
       await obniz.closeWait();
    }
    • with auto_connect:false

    If the param auto_connect is set as false, it will try to connect only once and, if unsuccessful, return false.

    var obniz = new Obniz('1234-5678',{auto_connect: false});
    
    var connected = await obniz.connectWait();  //try once
    
    if(connected){
      obniz.io0.output(true);
      await obniz.closeWait();
    }

    Parameters

    • Optional option: undefined | { timeout?: undefined | number }

    Returns Promise<boolean>

    False will be returned when connection is not established within a set timeout.

emit

  • Calls each of the listeners registered for a given event.

    Parameters

    Returns boolean

endCommandPool

  • endCommandPool(): null | any[]

endTrafficMeasurement

  • endTrafficMeasurement(): { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }
  • Returns { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }

    • ceilByte: number
    • readByte: number
    • readCount: number
    • sendByte: number
    • sendCount: number

eventNames

  • Return an array listing the events for which the emitter has registered listeners.

    Returns Array<ObnizConnectionEventNames | ObnizConnectionEventNamesInternal>

getAD

getExtraInterface

  • getExtraInterface(interfaceName: string): any

getFreeI2C

getFreePwm

getFreeSpi

getFreeTcp

  • getFreeTcp(): any
  • It returns unused TCP module.

    Returns any

getFreeUart

getI2CWithConfig

getIO

getSpiWithConfig

getTrafficData

  • getTrafficData(): { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }
  • Returns { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }

    • ceilByte: number
    • readByte: number
    • readCount: number
    • sendByte: number
    • sendCount: number

hasExtraInterface

  • hasExtraInterface(interfaceName: string): boolean

isValidAD

  • isValidAD(ad: any): boolean
  • Check the param is valid ad pin no.

    Parameters

    • ad: any

    Returns boolean

isValidIO

  • isValidIO(io: any): boolean
  • Check the param is valid io pin no.

    Parameters

    • io: any

    Returns boolean

keepWorkingAtOffline

  • keepWorkingAtOffline(working: any): void
  • By default, obniz Board resets after disconnection from the cloud. It means the output value and pwm will all stop at that point. But the above function with the argument true can nullify that default setting and change it to "do not reset when offline". This configuration remains as long as obniz Board is on.

    // Example
    obniz.keepWorkingAtOffline(true);

    Parameters

    • working: any

    Returns void

listenerCount

listeners

message

  • message(target: string | string[], message: string): void
  • Send message to obniz clients. If you want receive data, see Obniz.onmessage

    // Example
    obniz.onconnect = function(){
     var button = obniz.wired("Button",  {signal:0, gnd:1});
    
     button.onchange = function(){
       var targets = [
         "1234-1231",
         "1234-1232",
         "1234-1233",
         "1234-1234",
         "1234-1235",
         "1234-1236",
         "1234-1237",
         "1234-1238",
         "1234-1239",
         "1234-1230"];
    
       obniz.message(targets, "pressed");
      };
    }

    Parameters

    • target: string | string[]

      destination obniz id

    • message: string

      message data

    Returns void

off

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

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

    Returns this

on

once

pingWait

  • pingWait(unixtime?: undefined | number, rand?: undefined | number, forceGlobalNetwork?: undefined | false | true): Promise<void>
  • Ping to obniz device and wait pong response.

    If debugprint option enabled, it display ping/pong response time on console.

    await obniz.pingWait(); //waiting pong.

    Parameters

    • Optional unixtime: undefined | number

      start time of measure response time

    • Optional rand: undefined | number

      Unique identifier of ping data

    • Optional forceGlobalNetwork: undefined | false | true

    Returns Promise<void>

reboot

  • reboot(): void
  • reboot device

    obniz.reboot();

    Returns void

removeAllListeners

removeListener

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

    Parameters

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

    Returns this

repeat

  • repeat(callback: any, interval?: undefined | number): void
  • Set onloop function. Use onloop property instead. This is deprecated function.

    deprecated

    Parameters

    • callback: any
    • Optional interval: undefined | number

      default 100. It mean 100ms interval loop.

    Returns void

reset

  • reset(): void
  • This forces the obniz Board to go back to the initial state when the power was just turned on.

    // Example
    obniz = new Obniz("1234-5678");
    obniz.onconnect = function() {
      obniz.reset();
    }

    Returns void

resetOnDisconnect

  • resetOnDisconnect(reset: boolean): void
  • This lets you change the setting of reset_obniz_on_ws_disconnection after connection is established.

    By default, obniz cloud resets target obniz Board when the all websocket to obniz cloud was closed. It means the output value and pwm will all stop at that point. With the above function, you can nullify these resetting activities. This configuration will remain until target obniz Board gets disconnected. Set this function to false to keep working without any of the websocket connections.

    // Example
    obniz.resetOnDisconnect(false);

    Parameters

    • reset: boolean

    Returns void

resetTrafficMeasurement

  • resetTrafficMeasurement(): null | { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }
  • Returns null | { ceilByte: number; readByte: number; readCount: number; sendByte: number; sendCount: number }

send

  • send(obj: Record<string, any> | Record<string, any>[], options?: undefined | { connect_check?: undefined | false | true; local_connect?: undefined | false | true }): void
  • Send json/binary data to obniz Cloud or device.

    Parameters

    • obj: Record<string, any> | Record<string, any>[]

      send data

    • Optional options: undefined | { connect_check?: undefined | false | true; local_connect?: undefined | false | true }

      send option

    Returns void

setLoopInterval

  • setLoopInterval(interval: number): void
  • Sets the execution interval of onLoop function. Changes will be reflected after the next onloop is executed.

    Parameters

    • interval: number

      interval of execution in milliseconds.

    Returns void

setVccGnd

  • setVccGnd(vcc: number | null | undefined, gnd: number | null | undefined, drive: DriveType): void
  • Output pin Vcc and Gnd

    Parameters

    • vcc: number | null | undefined
    • gnd: number | null | undefined
    • drive: DriveType

    Returns void

sleep

  • sleep(date: Date): void
  • Action only with obniz Board 1Y.

    Obniz Board sleeps for the value specified in Date type. Sleep for up to 45 days (64800 minutes).

    // JavaScript example
    let dt = new Date();
    dt.setHours(dt.getHours () + 1,0,0,0);
    obniz.sleep(dt);

    Parameters

    • date: Date

    Returns void

sleepIoTrigger

  • sleepIoTrigger(trigger: boolean): void
  • Action only with obniz Board 1Y.

    It returns from sleep depending on the pin state of IO0.

    // JavaScript example
    obniz.sleepIoTrigger (true);

    Parameters

    • trigger: boolean
      • true: Rise (LOW -> HIGH)
      • false: Falling (HIGH -> LOW)

    Returns void

sleepMinute

  • sleepMinute(minute: number): void
  • Action only with obniz Board 1Y.

    Obniz Board sleeps for the value specified in minutes.

    // JavaScript example
    obniz.sleepMinute (60); // 60 minutes

    Parameters

    • minute: number

      up to 64800 minutes(45 days ).

    Returns void

sleepSeconds

  • sleepSeconds(sec: number): void
  • Action only with obniz Board 1Y.

    Obniz Board sleeps for the value specified in seconds.

    // JavaScript example
    obniz.sleepSeconds (60); // 60 seconds

    Parameters

    • sec: number

      up to 64800 seconds (18 hours).

    Returns void

startCommandPool

  • startCommandPool(): void

startTrafficMeasurement

  • startTrafficMeasurement(ceil?: number): void

wait

  • wait(msec: number): Promise<void>
  • This pauses obniz Board for a period given in terms of ms (millisecond).

    // Javascript Example
    led.on();
    obniz.wait(1000); // led ON 1sec.
    led.off();

    This method pauses only obniz Board, not JavaScript.

    // Javascript Example
    var time = new Date();
    led.on();
    obniz.wait(1000); // led ON 1sec.
    led.off();
    console.log((new Date()).getTime() - time.getTime()) // 0 or very few ms. not 1000ms.

    However, when you call this method together with the await function, JavaScript will pause for the given period in ms.

    // Javascript Example
    var time = new Date();
    led.on();
    await obniz.wait(1000); // led ON 1sec.
    led.off();
    console.log((new Date()).getTime() - time.getTime()) // => about 1000

    Parameters

    • msec: number

    Returns Promise<void>

wired

  • wired<K>(partsName: K, options?: PartsList[K]["options"]): Parts<K>
  • Setup Parts of parts library

    Type parameters

    Parameters

    • partsName: K
    • Optional options: PartsList[K]["options"]

    Returns Parts<K>

Static PartsRegistrate

  • PartsRegistrate(arg0: typeof ObnizPartsInterface, arg1?: any): void
  • Register Parts class

    Parameters

    • arg0: typeof ObnizPartsInterface

      Parts class

    • Optional arg1: any

      param for parts

    Returns void

Static getBleParts

Static getPartsClass

Static isIpAddress

  • isIpAddress(str: string): boolean

Static isValidObnizId

  • isValidObnizId(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Generated using TypeDoc