This function gets called when obniz Board finds a new peripheral.
// Javascript Example
obniz.ble.scan.onfind = function(peripheral){
console.log(peripheral)
};
await obniz.ble.initWait();
await obniz.ble.scan.startWait();
This function gets called when obniz Board finishes scanning.
// Javascript Example
obniz.ble.scan.onfind = function(peripheral){
console.log(peripheral)
};
obniz.ble.scan.onfinish = function(peripherals){
console.log("scan timeout!")
};
await obniz.ble.initWait();
await obniz.ble.scan.startWait();
Clear advertisement filter.
Use endWait() instead
This stops scanning BLE.
// Javascript Example
await obniz.ble.initWait();
await obniz.ble.scan.startWait();
await obniz.wait(5000);
await obniz.ble.scan.endWait();
Use startWait() instead.
This scans and returns all the peripherals found.
This function does not return until scanning gets timed out.(default 30sec) If you want to change the default duration, you can do so with the duration param.
// Javascript Example
await obniz.ble.initWait();
var target = {
uuids: ["fff0"],
};
var setting = {
duration : 10
}
var peripherals = await obniz.ble.scan.startAllWait(target,setting);
for(var peripheral of peripherals){
console.log(peripheral);
}
This scans and returns the first peripheral that was found among the objects specified in the target.
// Javascript Example
await obniz.ble.initWait();
var target = {
uuids: ["fff0"],
};
var peripheral = await obniz.ble.scan.startOneWait(target);
console.log(peripheral);
This starts scanning BLE.
You can filter uuids or localName using the target param.
// Javascript Example
var target = {
uuids: ["fff0","FFF1"], //scan only has uuids "fff0" and "FFF1"
localName: "obniz-BLE", //scan only has localName "obniz-BLE"
};
var setting = {
duration : 10 //scan duration time in seconds. default is 30 sec.
}
await obniz.ble.initWait();
await obniz.ble.scan.startWait(target, setting);
This is also possible without params being valid.
// Javascript Example
await obniz.ble.scan.startWait();
Scanning starts with no error and results with not advertisement found while a device is trying to connect a peripheral. Before start scannnig. Establishing connection must be completed or canceled.
Generated using TypeDoc