Abstract Optional options: ObnizOptionsOptional bleOptional displayOptional locationOptional motionOptional storageOptional switchOptional logicOptional measureOptional boot_This variable indicate installed boot reason of target device
var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
console.log(obniz.boot_reason) // ex. "DEEPSLEEP_RESET"
}
Optional connected_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.
}
This variable sets interval time to check connection state to obniz Device.
This let you know connection state to your obniz Board as string value.
var obniz = new Obniz('1234-5678');
console.log(obniz.connectionState) // => === "connecting"
obniz.onconnect = async function() {
console.log(obniz.connectionState) // => === "connected"
}
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_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 hwThis variable indicate connected hardware identifier of target device
var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
console.log(obniz.hw) // ex. "obnizb1"
}
obniz id
Readonly isIs node.js environment or not.
Optional metadataDevice metadata set on obniz cloud.
var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
console.log(obniz.metadata.description) // value for "description"
}
Optional oncloseonclose will be called when disconnected.
var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
}
obniz.onclose = async function() {
}
Optional onconnectOnce 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 onerrorIf 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 onloopCalled 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() {
}
Optional plugin_This variable indicate installed plugin_name of target device
var obniz = new Obniz('1234-5678');
obniz.onconnect = async function() {
console.log(obniz.plugin_name) // ex. "my_plugin"
}
Static prefixedOptional ad0Optional ad1Optional ad10Optional ad11Optional ad2Optional ad3Optional ad4Optional ad5Optional ad6Optional ad7Optional ad8Optional ad9Optional canbus0Optional i2c0Optional ioOptional io0Optional io1Optional io10Optional io11Optional io2Optional io3Optional io4Optional io5Optional io6Optional io7Optional io8Optional io9Optional pwm0Optional pwm1Optional pwm2Optional pwm3Optional pwm4Optional pwm5Optional spi0Optional spi1Optional uart0Optional uart1Optional componentsOptional wifiOptional pluginStatic versionobniz.js version
Optional context: anyThis 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();
}
replace with closeWait
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();
}
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();
var obniz = new Obniz('1234-5678');
await obniz.connectWait({timeout:10}); //timeout 10sec
if(connected){
obniz.io0.output(true);
await obniz.closeWait();
}
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();
}
Optional option: { Optional timeout?: numbertimeout in seconds
False will be returned when connection is not established within a set timeout.
Calls each of the listeners registered for a given event.
Rest ...args: any[]Return an array listing the events for which the emitter has registered listeners.
GET AD module from pin no
It returns unused I2C module.
It returns unused PWM module.
It returns unused SPI module.
It returns unused UART module.
It returns setuped I2C module .
Get IO module from pin no
It returns setuped SPI module.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Optional fn: ListenerFnOptional context: anyOptional once: booleanAdd a listener for a given event.
Optional context: anyAdd a one-time listener for a given event.
Optional context: anyAbstract pingRemove all listeners, or those of the specified event.
Optional event: ObnizConnectionEventNames | ObnizConnectionEventNamesInternalRemove the listeners of a given event.
Optional fn: ListenerFnOptional context: anyOptional once: booleanSend json/binary data to obniz Cloud or device.
send data
Optional options: { send option
Optional connect_Optional local_If false, send data via gloval internet.
Output pin Vcc and Gnd
Static PartsRegister Parts class
Parts class
Optional arg1: anyparam for parts
Static getStatic getGet parts class.
string
Static isGenerated using TypeDoc
If obnizOS ver >= 3.0.0, automatically load [[ObnizCore.Components.Ble.Hci.ObnizBLE|ObnizHciBLE]], and obnizOS ver < 3.0.0 throw unsupported Error,