diff --git a/lib/agent/providers/network/mac.js b/lib/agent/providers/network/mac.js index 33ce8d4a9..97b2cd8bf 100644 --- a/lib/agent/providers/network/mac.js +++ b/lib/agent/providers/network/mac.js @@ -75,22 +75,29 @@ exports.get_wireless_interfaces_list = (cb) => { exports.get_active_access_point_mac = (callback) => { let output; - accessPointsFn(airportCmd, ['-I'], (err, stdoutIn) => { - let stdout = stdoutIn; - if (err) return callback(err); - - stdout = stdout.toString().split('\n'); - stdout.forEach((line, index) => { - const data = line.split(': '); - if (data[0].trim() === 'BSSID') { - // eslint-disable-next-line prefer-destructuring - output = data[1]; - } - - if (index === stdout.length - 1) { - return callback(null, output); - } - }); + isAirportWorking((itWorks) => { + if (itWorks) { + accessPointsFn(airportCmd, ['-I'], (err, stdoutIn) => { + let stdout = stdoutIn; + if (err) return callback(err); + stdout = stdout.toString().split('\n'); + stdout.forEach((line, index) => { + const data = line.split(': '); + if (data[0].trim() === 'BSSID') { + // eslint-disable-next-line prefer-destructuring + output = data[1]; + } + if (index === stdout.length - 1) { + return callback(null, output); + } + }); + }); + } else { + socket.writeMessage('info', (error, apData) => { + if (error) return callback(error); + return callback(null, apData.mac_address); + }); + } }); };