How to use the getmac.getMac function in getmac

To help you get started, we’ve selected a few getmac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github physiii / open-automation / gateway_old.js View on Github external
if ('IPv4' !== iface.family || iface.internal !== false) {
      // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
      return;
    }
    if (alias >= 1) {
      // this single interface has multiple ipv4 addresses
      console.log(ifname + ':' + alias, iface.address);
    } else {
      // this interface has only one ipv4 adress
      console.log(ifname, iface.address);
    }
    ++alias;
  });
});

require('getmac').getMac(function(err,macAddress){
  if (err)  throw err
  mac = macAddress;
});

fs.stat('./device_info.json', function(err, stat) {
  if(err == null) {
    console.log('found device_info.json');
    var device_info = require("./device_info.json");
    device_info = JSON.parse(device_info);
    for(var i = 0; i < device_info.length; i++) {
      mac = device_info[i].mac;
      token = device_info[i].token;
      //io_relay.emit('token',{token:token});    
      console.log(mac + " | " + token);
    }
  } else if(err.code == 'ENOENT') {
github coreybutler / fenix / src / lib / api / router.js View on Github external
});
            conn.on('close',function(){
              me.emit('socketclose');
            });
          });
          }
          return this._socket;
        }
      }

    });

    var me = this;

    // Get the computer's MAC address
    require('getmac').getMac(function(err,addr){
      if (err) throw err;
      me.MAC = addr;
      me.computer = addr;
    });

    // Boot up the socket server
    this.socket.listen(336490,function(){
      me.emit('socketready');
    });
  },
github physiii / open-automation / server.js View on Github external
var EventEmitter = require("events").EventEmitter;
var body = new EventEmitter();

var d = new Date();
var light_delay = 0; //command delay in ms
var previous_data = 0;

var username = "init";
var device_name = "init";
var mac = "init";
var ip = "init";
var device_port = "init";


// Fetch the computer's mac address 
require('getmac').getMac(function(err,macAddress){
  if (err)  throw err
  mac = macAddress;
})

/////////////////////////////////////////
    
body.on('update', function () {
  var token = body.data;
  console.log('user '+username+' | token '+token+' | mac '+mac+' | ip '+ip+' | port '+device_port+' | device_name '+ device_name);
  
  /*query = "insert";
  connection.query(query, function(err, rows, fields) {
    if (err) {
      //console.log('table already exist');  
    } else {
      console.log('created gateway_table');  
github coreybutler / fenix / src / lib / api / requestbin.js View on Github external
* Indicates whether the bin is shared publicly or not.
       * @private
       */
      shared: {
        enumerable: false,
        writable: true,
        configurable: false,
        value: false
      }

    });

    var me = this;

    // Get the computer's MAC address
    require('getmac').getMac(function(err,addr){
      if (err) throw err;
      me.MAC = addr;
      me.computer = addr;

      // Handle all requests
      me.app.head('/ping_fenix',function(req,res){
        res.send(200);
        return;
      });
      me.app.all('/*',function(req,res){
        if(req.url !== '/fenix_ping'){
          me.addRequest({
            method: req.method,
            headers: req.headers,
            body: req.body.replace(/\/gi,'>'),
            query: req.query,
github physiii / open-automation / gateway / utils.js View on Github external
function get_mac () {
  require('getmac').getMac(function(err,macAddress){
    if (err)  throw err
    mac = macAddress.replace(/:/g,'').replace(/-/g,'').toLowerCase();
    var token = crypto.createHash('sha512').update(mac).digest('hex');
    console.log("Device ID: " + mac);
    module.exports.mac = mac;
  });
}
github physiii / open-automation / controllers / gateway.js View on Github external
function get_mac () {
require('getmac').getMac(function(err,macAddress){
  if (err)  throw err
  mac = macAddress.replace(/:/g,'').replace(/-/g,'').toLowerCase();
  store_settings({mac:mac});
  console.log("Enter device ID (" + mac + ") at http://pyfi.org");
    var hostapd_file = "interface=wlan0\n"
		       + "driver=nl80211\n"
		       + "ssid=Gateway " + mac + "\n"
		       + "hw_mode=g\n"
		       + "channel=6\n"
		       + "ieee80211n=1\n"
		       + "wmm_enabled=1\n"
		       + "ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]\n"
		       + "macaddr_acl=0\n"
		       + "auth_algs=1\n"
		       + "ignore_broadcast_ssid=0\n"
		       + "wpa=2\n"
github matrix-io / matrix-os / lib / service / initialize.js View on Github external
wifiManager.status(function(currentStatus) {
                  var details = device;
                  var pathToPhoto = routes.currentPhotosFolder;
                  var imagePath = pathToPhoto + '/lastPhoto.jpg';
                  details.network = currentStatus;
                  delete details.deviceToken;

                  require('getmac').getMac(function(err, macAddress) {
                    details.deviceId = macAddress;

                    fileManager.exists(path.root + "public/files/orientation", function(exists) {
                      if (exists === false) {
                        fileManager.createParamValueFile({
                          orientation: 0
                        }, "orientation");
                      }

                      fileManager.readParamValueFile("orientation", function(orientationJson) {
                        var orientation;
                        if (!orientationJson || typeof orientationJson.orientation == 'undefined') {
                          orientation = 0;
                        } else {
                          orientation = orientationJson.orientation;
                        }
github matrix-io / matrix-os / lib / api / auth.js View on Github external
registerAnonymousDevice: function(device, client, callback) {
      var url = config.url.device.registerAnonymous;

      require('getmac').getMac(function(err, macAddress) {
        if (err) throw err;

        Matrix.activeDevice.deviceId = macAddress;

        params = {
          device_id: device.getDeviceId(),
          client_token: client.getAccessToken(),
          name: device.getName(),
          description: device.getDescription()
        };

        request.post({
          url: url,
          form: params
        }, function(error, response, body) {
github heremaps / here-cli / bin / common.js View on Github external
function encryptAndStore(key,toEncrypt) {
    require('getmac').getMac(function (err, macAddress) {
        if (err) throw err
        secretKey = macAddress;
        var CryptoJS = require("crypto-js");
        var ciphertext = CryptoJS.AES.encrypt(toEncrypt, secretKey);
        settings.set(key, ciphertext.toString());
    });
}

getmac

Get the MAC address of the current machine you are on.

Artistic-2.0
Latest version published 12 months ago

Package Health Score

68 / 100
Full package analysis

Popular getmac functions