ok integrated “hcitool con”, because of the very fast response,
had to alter the parsing of NetworkScanner.
i think i got the parsing, but networkscanner says NO DEVICES
when i “console.log(macAddresses)” , at the end of node_helper script i get during MM in console :
MMM-NetworkScanner received SCAN_NETWORK
MMM-NetworkScanner is scanning for mac addresses
[ ‘E0:E5:CF:FC:4D:8C’ ]
shouldn’t this “macAddresses parse” be understand by NetworkScanner? What am i missing here?
nodehelper script is as follows:
scanNetwork: function() {
console.log(this.name + " is scanning for mac addresses");
var self = this;
var arp = sudo(['hcitool', 'con']);
var buffer = '';
var errstream = '';
arp.stdout.on('data', function (data) {
buffer += data;
});
arp.stderr.on('data', function (data) {
errstream += data;
});
arp.on('error', function (err) {
errstream += err;
});
arp.on('close', function (code) {
if (code !== 0) {
console.log(self.name + " received an error running arp-scan: " + code + " - " + errstream);
return;
}
//Parse the response
var rows = buffer.split('\n');
var macAddresses = [];
// HCI-TOOL SCAN table
for (var i = 1; i < rows.length; i++) {
var cells = rows[i].split(' ').filter(String);
if (cells[2] && macAddresses.indexOf(cells[2].toUpperCase()) === -1) {
macAddresses.push(cells[2].toUpperCase());
}
}
self.sendSocketNotification('MAC_ADDRESSES', macAddresses);
console.log(macAddresses);
});
}
Note from admin: Please use Markdown on code snippets for easier reading!