Added support for remote + passworded access

This password encoder was decompiled from the Android app then manually cleaned up and ported to Javascript. It ain't pretty, but it works.

I don't know that this is all necessarily the most correct or idiomatic way to implement these features, but I wanted to make sure the functionality got committed to help out people wanting to use this for smart home appliances (#1).
This commit is contained in:
2019-02-22 15:21:49 -06:00
parent ba734517c9
commit a09df2569b
8 changed files with 371 additions and 13 deletions

View File

@ -2,17 +2,36 @@
const ScreenLogic = require('./index');
var finder = new ScreenLogic.FindUnits();
finder.on('serverFound', function(server) {
finder.close();
connect(new ScreenLogic.UnitConnection(server));
});
// use this to find and connect to units local to the network this is running on
// var finder = new ScreenLogic.FindUnits();
// finder.on('serverFound', function(server) {
// finder.close();
// connect(new ScreenLogic.UnitConnection(server));
// });
//
// finder.search();
finder.search();
// use this instead of the above `finder` logic if you want to use a direct connection
// use this if you want to use a direct connection to a known unit
// connect(new ScreenLogic.UnitConnection(80, '10.0.0.85'));
// use this to remote connect to a system by name (going through the Pentair servers)
const systemName = 'Pentair: xx-xx-xx';
const password = '1234';
var remote = new ScreenLogic.RemoteLogin(systemName);
remote.on('gatewayFound', function(unit) {
remote.close();
if (unit && unit.gatewayFound) {
console.log('unit ' + remote.systemName + ' found at ' + unit.ipAddr + ':' + unit.port);
connect(new ScreenLogic.UnitConnection(unit.port, unit.ipAddr, password));
} else {
console.log('no unit found by that name');
}
});
remote.connect();
// generic connection method used by all above examples
function connect(client) {
client.on('loggedIn', function() {
this.getVersion();
@ -40,6 +59,9 @@ function connect(client) {
}).on('controllerConfig', function(config) {
console.log(' controller is in celsius=' + config.degC);
client.close();
}).on('loginFailed', function() {
console.log(' unable to login (wrong password?)');
client.close();
});
client.connect();