Added decoding of messages
Also moved things out to their own files and setup require()s to bring it all together.
This commit is contained in:
41
test.js
41
test.js
@ -1,18 +1,23 @@
|
||||
const ScreenLogic = require('./index');
|
||||
|
||||
var finder = new ScreenLogic.FindUnits();
|
||||
finder.on('serverFound', function(server) {
|
||||
var client = new ScreenLogic.UnitConnection(server);
|
||||
client.on('loggedIn', function() {
|
||||
this.getPoolStatus();
|
||||
this.getControllerConfig();
|
||||
}).on('poolStatus', function(status) {
|
||||
}).on('controllerConfig', function(config) {
|
||||
client.close();
|
||||
finder.close();
|
||||
});
|
||||
|
||||
client.connect();
|
||||
});
|
||||
|
||||
finder.search();
|
||||
const ScreenLogic = require('./index');
|
||||
|
||||
var finder = new ScreenLogic.FindUnits();
|
||||
finder.on('serverFound', function(server) {
|
||||
var client = new ScreenLogic.UnitConnection(server);
|
||||
client.on('loggedIn', function() {
|
||||
this.getPoolStatus();
|
||||
this.getControllerConfig();
|
||||
}).on('poolStatus', function(status) {
|
||||
console.log(" pool ok=" + status.ok);
|
||||
console.log(" air temp=" + status.airTemp);
|
||||
console.log(" salt ppm=" + status.saltPPM * 50);
|
||||
console.log(" pH=" + status.pH / 100);
|
||||
}).on('controllerConfig', function(config) {
|
||||
console.log(" controller is in celsius=" + config.degC);
|
||||
client.close();
|
||||
finder.close();
|
||||
});
|
||||
|
||||
client.connect();
|
||||
});
|
||||
|
||||
finder.search();
|
||||
|
Reference in New Issue
Block a user