forked from puppy0cam/wemo-finder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (25 loc) · 949 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var Client = require('node-ssdp').Client;
var Finder = module.exports = function () {
if (Finder.client === undefined) {
Finder.client = new Client();
Finder.devices = [];
Finder.client.on('response', function (headers, statusCode, rinfo) {
var Send = {
'headers': headers,
'statusCode': statusCode,
'rinfo': rinfo,
'ip': headers.LOCATION.slice(7, headers.LOCATION.length - 10)
};
Finder.devices[Finder.devices.length] = Send;
console.log('\x1b[44m\x1b[33m<<<\x1b[32m WEMO DEVICE FOUND \x1b[33m>>>\x1b[0m');
console.log('\x1b[44m\x1b[33m<<<\x1b[32m IP: ' + Send.ip + ' \x1b[33m>>>\x1b[0m');
});
// search for a service type
Finder.client.search("urn:Belkin:device:controllee:1");
console.log('\x1b[44m\x1b[33m<<<\x1b[32m LOADED FINDER \x1b[33m>>>\x1b[0m');
return "made by puppy0cam A.K.A. Cameron";
} else {
Finder.devices = [];
Finder.client.search("urn:Belkin:device:controllee:1");
}
};