Skip to content

Commit

Permalink
new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bikerp committed Jan 6, 2016
1 parent f1a3d4a commit 8b1854f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
16 changes: 3 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,20 @@ var fs = require('fs');

var OUTPUT_FILE = "result.txt";
var LOGIN_USER = "admin";
var LOGIN_PWD = "160973";
var LOGIN_PWD = "<PIN CODE>";
var HNAP_URL = "http://192.168.1.128/HNAP1";
//var HNAP_URL = "http://192.168.0.60/HNAP1";
var POLLING_INTERVAL = 60000;

soapclient.login(LOGIN_USER, LOGIN_PWD, HNAP_URL).done(function (status) {
if (!status) {
throw "Login failed!";
}
if (status!="success") {
if (status != "success") {
throw "Login failed!";
}
start();
//read();
read();
});

function start(){
soapclient.getInternetSettings().done(function (result){
//soapclient.on().done(function (result){
console.log(result);
//read();
})
}

function read() {
soapclient.consumption().done(function (power) {
soapclient.temperature().done(function (temperature) {
Expand Down
39 changes: 15 additions & 24 deletions js/soapclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ function soapAction(method, responseElement, body) {
},
body: body
}).then(function (response) {
console.log(response.getBody(HNAP_BODY_ENCODING));
return readResponseValue(response.getBody(HNAP_BODY_ENCODING), responseElement);
}).catch(function (err) {
console.log("error:", err);
Expand Down Expand Up @@ -165,10 +164,6 @@ exports.setFactoryDefault = function () {
return soapAction("SetFactoryDefault", "SetFactoryDefaultResult", requestBody("SetFactoryDefault", ""));
};

exports.setFactoryDefault = function () {
return soapAction("SetFactoryDefault", "SetFactoryDefaultResult", requestBody("SetFactoryDefault", ""));
};

exports.getWLanRadios = function () {
return soapAction("GetWLanRadios", "GetWLanRadiosResult", requestBody("GetWLanRadios", ""));
};
Expand All @@ -186,24 +181,20 @@ exports.settriggerADIC = function () {
};

function APClientParameters(group) {
return "<Enabled>true</Enabled>"+
"<RadioID>RADIO_2.4GHz</RadioID>"+
"<SSID>CiscoHome_ext</SSID>"+
"<MacAddress>C8:D7:19:4D:F9:F0</MacAddress>"+
"<ChannelWidth>0</ChannelWidth>"+
"<SupportedSecurity>"+
"<SecurityInfo>"+
"<SecurityType>WPA2-PSK</SecurityType>"+
"<Encryptions>"+
"<string>AES</string>"+
"</Encryptions>"+
"</SecurityInfo>"+
"</SupportedSecurity>"+
"<Key>"+AES.AES_Encrypt128("lotusnotes", HNAP_AUTH.PrivateKey)+"</Key>";
}

function testParameters(group) {
return "<ModuleGroupID>" + group + "</ModuleGroupID>";
return "<Enabled>true</Enabled>" +
"<RadioID>RADIO_2.4GHz</RadioID>" +
"<SSID>My_Network</SSID>" +
"<MacAddress>XX:XX:XX:XX:XX:XX</MacAddress>" +
"<ChannelWidth>0</ChannelWidth>" +
"<SupportedSecurity>" +
"<SecurityInfo>" +
"<SecurityType>WPA2-PSK</SecurityType>" +
"<Encryptions>" +
"<string>AES</string>" +
"</Encryptions>" +
"</SecurityInfo>" +
"</SupportedSecurity>" +
"<Key>" + AES.AES_Encrypt128("password", HNAP_AUTH.PrivateKey) + "</Key>";
}

function groupParameters(group) {
Expand Down Expand Up @@ -247,7 +238,7 @@ function getHnapAuth(SoapAction, privateKey) {
}

function readResponseValue(body, elementName) {
if(body && elementName) {
if (body && elementName) {
var doc = new DOMParser().parseFromString(body);
var node = doc.getElementsByTagName(elementName).item(0);
return (node) ? node.firstChild.nodeValue : "ERROR";
Expand Down

0 comments on commit 8b1854f

Please sign in to comment.