forked from mapero/Fritzbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
53 lines (50 loc) · 1.71 KB
/
test.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var Fritzbox = require("./lib/Fritzbox");
var Promise = require("bluebird");
var options = {
host: "fritz.box",
port: 49443,
ssl: true,
user: "user",
password: "password",
serverPort: 52400,
serverAddress: "192.168.80.37"
};
var box = new Fritzbox.Fritzbox(options);
//Initialize Device
Promise.all([box.initTR064Device(), box.initIGDDevice()])
//Print information about available services
.then(function() {
for (var serviceName in box.services) {
console.log("=== "+serviceName+" ===");
for (var actionName in box.services[serviceName].actionsInfo) {
console.log(" # " + actionName + "()");
box.services[serviceName].actionsInfo[actionName].inArgs.forEach(function(arg) {
console.log(" IN : " + arg);
});
box.services[serviceName].actionsInfo[actionName].outArgs.forEach(function(arg) {
console.log(" OUT : " + arg);
});
}
}
console.log(box.listServices());
})
.then(function() {
return Promise.all([
box.services["urn:dslforum-org:service:LANHostConfigManagement:1"].subscribe(),
box.services["urn:dslforum-org:service:WLANConfiguration:1"].subscribe(),
box.services["urn:dslforum-org:service:WLANConfiguration:2"].subscribe(),
box.services["urn:dslforum-org:service:Hosts:1"].subscribe(),
box.services["urn:schemas-upnp-org:service:WANIPConnection:1"].subscribe()
]);
}).then(function(result) {
result.forEach(function(sid) {
console.log("Subscribed: "+sid);
});
return box.services["urn:dslforum-org:service:Hosts:1"].actions.GetHostNumberOfEntries();
})
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.log(err);
});