Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var mdf = new MarantzDenonUPnPDiscovery(function(error, device) {
## Tested on?

* marantz SR7011
* marantz M-CR510



Expand Down
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ var parseString = require('xml2js').parseString;
@param {function} callback .
@constructor
*/
function MarantzDenonUPnPDiscovery(callback) {
function MarantzDenonUPnPDiscovery(cb) {
var that = this;
var foundDevices = {}; // only report a device once

var callback = function (error, device) {
if (device.manufacturer.match(/(^marantz$)|(^denon$)/i)) {
cb(error, device);
}
}

// create socket
var socket = dgram.createSocket({type: 'udp4', reuseAddr: true});
socket.unref();
Expand All @@ -43,8 +49,6 @@ function MarantzDenonUPnPDiscovery(callback) {

socket.on('message', function(message, rinfo) {
var messageString = message.toString();
console.log(messageString);
if (messageString.match(/(d|D)enon/)) {
location = messageString.match(/LOCATION: (.*?)(\d+\.\d+\.\d+\.\d+)(.*)/);
if (location) {
arp.getMAC(location[2], function(err, mac) { // lookup ip on the arp table to get the MacAddress
Expand All @@ -71,7 +75,6 @@ function MarantzDenonUPnPDiscovery(callback) {
}
});
}
}
});

socket.on('listening', function() {
Expand Down