Skip to content

Commit

Permalink
Merge pull request #127 from Mozoloa/Alt-Xinfo
Browse files Browse the repository at this point in the history
Change method to retrieve broadcast addresses and update probe to use…
  • Loading branch information
istnv authored Dec 21, 2024
2 parents 77a21cd + 07a66b1 commit de61950
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
49 changes: 39 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,54 @@ class BAirInstance extends InstanceBase {
this.checkFeedbacks(...Object.keys(this.blinkingFB))
}

/**
* Get broadcast addresses for all local IPv4 interfaces.
* @returns {string[]} An array of broadcast addresses (e.g., ["192.168.1.255", ...]).
*/
getBroadcastAddresses() {
const os = require('os');
const interfaces = os.networkInterfaces();
const broadcastAddresses = [];

for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name]) {
if (iface.family === 'IPv4' && !iface.internal) {
// Calculate broadcast address by replacing the last octet with 255
const parts = iface.address.split('.');
parts[3] = '255';
broadcastAddresses.push(parts.join('.'));
}
}
}

return broadcastAddresses;
}


/**
*
* network scanner interval
*/
probe() {
const broadcastAddresses = this.getBroadcastAddresses();

if (!(this.probeCount % 6)) {
// scan every 30 seconds
this.scanPort.send(
{
address: '/xinfo',
args: [],
},
'255.255.255.255',
10024
)
// Scan every 30 seconds
for (const broadcast of broadcastAddresses) {
this.scanPort.send(
{
address: '/xinfo',
args: [],
},
broadcast,
10024
);
}
}
this.probeCount++
this.probeCount++;
}


/**
* Gather list of local mixer IP numbers and names
*/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "behringer-xair",
"version": "2.6.3",
"version": "2.6.4",
"type": "module",
"main": "index.js",
"scripts": {
Expand All @@ -19,4 +19,4 @@
"devDependencies": {
"@companion-module/tools": "^2.1.0"
}
}
}

0 comments on commit de61950

Please sign in to comment.