Skip to content

Commit

Permalink
added new methods
Browse files Browse the repository at this point in the history
new method for initial setup
  • Loading branch information
bikerp committed Jan 4, 2016
1 parent 103cdfc commit bfc43bd
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 9 deletions.
9 changes: 6 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ var fs = require('fs');

var OUTPUT_FILE = "result.txt";
var LOGIN_USER = "admin";
var LOGIN_PWD = "PIN CODE";
var LOGIN_PWD = "160973";
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) {
Expand All @@ -22,12 +23,14 @@ soapclient.login(LOGIN_USER, LOGIN_PWD, HNAP_URL).done(function (status) {
throw "Login failed!";
}
start();
//read();
});

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

Expand Down
91 changes: 85 additions & 6 deletions js/soapclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var md5 = require('./hmac_md5');
var request = require('then-request');
var DOMParser = require('xmldom').DOMParser;
var fs = require("fs");
var AES = require('./AES');

var HNAP1_XMLNS = "http://purenetworks.com/HNAP1/";
var HNAP_METHOD = "POST";
Expand Down Expand Up @@ -104,7 +105,7 @@ exports.temperature = function () {
return soapAction("GetCurrentTemperature", "CurrentTemperature", requestBody("GetCurrentTemperature", moduleParameters(3)));
};

exports.radioSettings = function () {
exports.getAPClientSettings = function () {
return soapAction("GetAPClientSettings", "GetAPClientSettingsResult", requestBody("GetAPClientSettings", radioParameters("RADIO_2.4GHz")));
};

Expand Down Expand Up @@ -132,13 +133,89 @@ exports.triggerWirelessSiteSurvey = function () {
return soapAction("SetTriggerWirelessSiteSurvey", "SetTriggerWirelessSiteSurveyResult", requestBody("SetTriggerWirelessSiteSurvey", radioParameters("RADIO_2.4GHz")));
};

exports.latestDetection = function () {
return soapAction("GetLatestDetection", "GetLatestDetectionResult", requestBody("GetLatestDetection", moduleParameters(2)));
};

exports.reboot = function () {
return soapAction("Reboot", "RebootResult", requestBody("Reboot", ""));
};

exports.isDeviceReady = function () {
return soapAction("IsDeviceReady", "IsDeviceReadyResult", requestBody("IsDeviceReady", ""));
};

exports.getModuleSchedule = function () {
return soapAction("GetModuleSchedule", "GetModuleScheduleResult", requestBody("GetModuleSchedule", moduleParameters(0)));
};

exports.getModuleEnabled = function () {
return soapAction("GetModuleEnabled", "GetModuleEnabledResult", requestBody("GetModuleEnabled", moduleParameters(0)));
};

exports.getModuleGroup = function () {
return soapAction("GetModuleGroup", "GetModuleGroupResult", requestBody("GetModuleGroup", groupParameters(0)));
};

exports.getScheduleSettings = function () {
return soapAction("GetScheduleSettings", "GetScheduleSettingsResult", requestBody("GetScheduleSettings", ""));
};

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", ""));
};

exports.getInternetSettings = function () {
return soapAction("GetInternetSettings", "GetInternetSettingsResult", requestBody("GetInternetSettings", ""));
};

exports.setAPClientSettings = function () {
return soapAction("SetAPClientSettings", "SetAPClientSettingsResult", requestBody("SetAPClientSettings", APClientParameters()));
};

exports.settriggerADIC = function () {
return soapAction("SettriggerADIC", "SettriggerADICResult", requestBody("SettriggerADIC", ""));
};

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>";
}

function groupParameters(group) {
return "<ModuleGroupID>" + group + "</ModuleGroupID>";
}
function temperatureSettingsParameters(module) {
return moduleParameters(module) +
"<NickName>TemperatureMonitor 3</NickName>" +
"<Description>Temperature Monitor 3</Description>" +
"<UpperBound>90</UpperBound>" +
"<UpperBound>80</UpperBound>" +
"<LowerBound>Not Available</LowerBound>" +
"<OPStatus>false</OPStatus>";
"<OPStatus>true</OPStatus>";
}
function powerWarningParameters() {
return "<Threshold>28</Threshold>" +
Expand Down Expand Up @@ -170,7 +247,9 @@ function getHnapAuth(SoapAction, privateKey) {
}

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

0 comments on commit bfc43bd

Please sign in to comment.