When using multiple obnizBLEGateway, the system will still be able to use
It is almost the same as the case of a single unit.
The system configuration looks like this
The basic program flow is as follows:
- Establish a connection to multiple obniz devices.
- initialize the BLE system
- start scan for peripheral BLE devices
- save the scan results to a database or other location
- repeat 3 to 4.
Here's what it looks like in concrete terms.
const Obniz = require('obniz');
var obnizIdList = [
"OBNIZ_ID_A_HERE",
"OBNIZ_ID_B_HERE",
"OBNIZ_ID_C_HERE",
"OBNIZ_ID_D_HERE"
]
for(let obnizId of obnizIdList){
var obniz = new Obniz(obnizId);
// Establish a connection to multiple obniz devices.
obniz.onconnect = async function () {
//initialize the BLE system
await obniz.ble.initWait();
obniz.ble.scan.onfind = async function(peripheral){
console.log(peripheral.localName);
// save the scan results to a database or other location
sendToDatabase(peripheral);
};
obniz.ble.scan.onfinish = async function(peripherals, error){
console.log("scan timeout!")
// start scan for peripheral BLE devices
await obniz.ble.scan.startWait();
};
// start scan for peripheral BLE devices
await obniz.ble.scan.startWait();
}
}
function sendToDatabase() {
}
Can you see that the program is almost the same as the one used for one unit?
By customizing the above program, you can have more detailed control.
Please refer to How to use BLE in obnizjs to customize the program.
For example, here are some articles that can help you
If you want to narrow down your scan results
Set ScanTarget in conditional searchI want to reduce the amount of communication.
Filter by device to reduce traffic E3%82%A3%E3%83%AB%E3%82%BF%E3%83%AA%E3%83%B3%E3%82%B0%E3%82%92%E3%81%97%E3%81%A6%E9%80%9A%E4%BF%A1%E9%87%8F%E3%82%92%E5%89%8A%E6%B 8%9B%E3%81%99%E3%82%8B)
- I want to scan all the time, not just every 30 seconds.
Set up ScanSetting in conditional search
- I want to receive multiple advertisements from the same device
Set up ScanSetting in conditional search
The basic flow of the program is as follows
Establish a connection with an obniz device
2. initialize the BLE system
3. perform a scan for peripheral BLE devices
4. save the scan results to a database or other location
5. repeat 3 to 4.