this.on("input", function(msg) { var mac = this.mac || msg.mac || null; var host = this.host || msg.host || '255.255.255.255'; var h = host.split('.'); h.pop(); h.push('255'); host = h.join('.'); if (mac != null) { if (chk.test(mac)) { try { wol.wake(mac, {address: host}, function(error) { if (error) { node.warn(error); node.status({fill:"red",shape:"ring",text:" "}); } else if (RED.settings.verbose) { node.log("sent WOL magic packet"); node.status({fill:"green",shape:"dot",text:" "}); } }); } catch(e) { if (RED.settings.verbose) { node.log("WOL: socket error"); } } } else { node.warn('WOL: bad mac address "'+mac+'"'); } } else { node.warn("WOL: no mac address specified"); } });
(callback) => { wol.wake(e.mac, { address: config.WakeOnLan.broadcast }, (err) => { callback(err); }); },
arpTable.fetch(function(err, table) { for(var i in table) { if(table[i].ip === that.ip) { wol.wake(table[i].mac); } } });
module.powerOn = function (mac) { console.log('node-sonytv::SonyTV: Power On command sent...'); if (mac !== undefined && mac !== '') { wol.wake(mac); return true; } return false; }
socket.on("wake", function() { if(conf.mac) { wol.wake(conf.mac, function(err) { if(err) console.log(err); else { console.log("success?") } }) } else { console.log("this would probably cause my client to wake"); } });
exports.post = function (req, res) { console.log('wol: ' + req.params.mac); try { wol.wake(req.params.mac, {}, function(err) { if (err) { console.log('WOL failed: ' + err.message); res.send(500, err.message); } else { res.send(200); } }); } catch (err) { res.status(400).send(err.message); } };
computers.findAll(function (err, computers) { var result; if (err) { console.err('Error getting list of computers from DB.'); return; } result = computers.filter(function (computer) { return computer.mac === mac; }); if (result.length > 0) { wol.wake(result[0].mac, { address: ip.or(result[0].ip, '0.0.0.255') }); console.log('Magic packet sent to: ' + result[0].mac + '(' + ip.or(result[0].ip, '0.0.0.255') + ')'); } res.redirect('/ping/' + result[0].ip); });
SonyTV.prototype._control = function(state, callback) { if(state){ wol.wake(this.mac, function(error) { if (error) { this._service.setCharacteristic(Characteristic.On, false); this.log("Error when sending packets", error); } else { this.log("Packets sent"); this._service.setCharacteristic(Characteristic.On, false); } }.bind(this)); }else{ var post_data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http:\/\/schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>AAAAAQAAAAEAAAAvAw==</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"; if (this.comp == "true"){ var post_options = { host: 'closure-compiler.appspot.com', port: '80', path: '/sony/IRCC', method: 'POST', headers: {} }; }else{ // An object of options to indicate where to post to var post_options = { host: this.ip, port: '80', path: '/IRCC', method: 'POST', headers: {} }; // Set up the request var post_req = http.request(post_options, function(res) { res.setEncoding('utf8'); res.on('data', function (chunk) { this._service.setCharacteristic(Characteristic.On, false); }); }); // post the data post_req.write(post_data); post_req.end(); } } }
Bravia.prototype.wake = function() { var that = this; if (this.mac) { wol.wake(this.mac); } else { arpTable.fetch(function(err, table) { for(var i in table) { if(table[i].ip === that.ip) { wol.wake(table[i].mac); } } }); } };
exports.wake = function(params) { var macaddress; if ((!params) || (!params.ipaddress)) return false; if (!arptab[params.ipaddress]) { logger.warning('no MAC address for ' + params.ipaddress); return false; } macaddress = arptab[params.ipaddress].toUpperCase(); wakeonlan.wake(macaddress, { ipaddress: params.ipaddress }, function(err) { if (!!err) return logger.error('unable to wake ' + macaddress + ' for ' + params.ipaddress); logger.notice('woke ' + macaddress + ' for ' + params.ipaddress); }); return true; };
this.on("input", function(msg) { var mac = this.mac || msg.mac || null; var host = this.host || msg.host || '255.255.255.255'; if (mac != null) { if (chk.test(mac)) { try { wol.wake(mac, {address: host}, function(error) { if (error) { node.warn(error); } else if (RED.settings.verbose) { node.log("sent WOL magic packet"); } }); } catch(e) { if (RED.settings.verbose) { node.log("WOL: socket error"); } } } else { node.warn('WOL: bad mac address "'+mac+'"'); } } else { node.warn("WOL: no mac address specified"); } });
SynologyAccessory.prototype.setPowerState = function (powerState, callback) { if (powerState) { //turn on wol.wake(this.mac, function (error) { if (!error) { this.log('Diskstation woken up'); callback(null) } else { this.log(error); callback(error); } }.bind(this)); } else { //turn off request({url: this.url + '/webapi/auth.cgi', qs: this.params.login, method: 'GET', timeout: 3000}, function (error, response, body) { if (!error && response.statusCode == 200) { var res = JSON.parse(body); if (res.success) { this.params.shutdown._sid = res.data.sid; request({url: this.url + '/webapi/dsm/system.cgi', qs: this.params.shutdown, method: 'GET'}, function (error, response, body) { if (!error && response.statusCode == 200 && JSON.parse(body).success) { this.log('Diskstation shuts down.'); callback(null); } else { this.log(error || new Error('undefinied error')); callback(error); } }.bind(this)); } } else { this.log(error || new Error('Can not connect to Diskstation')); callback(error); } }.bind(this)); } };
httpRequest: function(url, body, method, username, password, sendimmediately, callback) { if (url.substring( 0, 3).toUpperCase() == "WOL") { //Wake on lan request var address = parse( url); var opts={}; var macAddress = address.mac; if (address.ip) { opts.address = address.ip; } this.log("Excuting WakeOnLan request to "+macAddress+" options: "+JSON.stringify( opts)); wol.wake(macAddress, opts, function(error) { if (error) { callback( error); } else { callback( null, 200, "OK"); } }); } else { request({ url: url, body: body, method: method, rejectUnauthorized: false, timeout: 3000, auth: { user: username, pass: password, sendImmediately: sendimmediately } }, function(error, response, body) { callback(error, response, body) }); } },
var new_alarm = setTimeout(function () { console.log("Trying to wake up " + req.body.device.id + "..."); wol.wake(req.body.device.id); delete alarms[next]; }, delta);
(callback) => { wol.wake(e.mac, (e) => { callback(e); }); },