UNPKG

noble

Version:

A Node.js BLE (Bluetooth Low Energy) central library.

19 lines (14 loc) 432 B
var child_process = require('child_process'); function localAddress(callback) { child_process.exec('system_profiler SPBluetoothDataType', {}, function(error, stdout, stderr) { var address = null; if (!error) { var found = stdout.match(/\s+Address: (.*)/); if (found) { address = found[1].toLowerCase().replace(/-/g, ':'); } } callback(address); }); } module.exports = localAddress;