obniz to be used
Rsponse waiting timeout in milliseconds
Initialized status.
// Javascript Example
obniz.ble.isInitialized; // => false
await obniz.ble.initWait();
obniz.ble.isInitialized; // => true
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");
}
peripheral device address
"random" or "public"
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");
}
peripheral device address
"random" or "public"
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Return connected peripherals.
// Javascript Example
await obniz.ble.initWait();
let target = {
localName: "Blank"
};
var peripheral = await obniz.ble.scan.startOneWait(target);
if(peripheral) {
try {
await peripheral.connectWait();
} catch(e) {
console.error(e);
}
}
console.log(obniz.ble.getConnectedPeripherals());
connected peripherals
Initialize BLE module. You need call this first everything before. This throws if device is not supported device.
// Javascript Example
await obniz.ble.initWait();
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Add a listener for a given event.
Add a one-time listener for a given event.
Remove all listeners, or those of the specified event.
Remove the listeners of a given event.
Reset Target Device and current SDK status without rebooting. If error occured while reset, then target device will reboot.
// Javascript Example
await obniz.ble.resetWait();
Generated using TypeDoc
Use a obniz device as a BLE device. Peripheral and Central mode are supported