Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion manualtest/test-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ var connection = knx.Connection({
process.stdin.on('data', (data) => {
console.log(JSON.stringify(data));
if (data[0] === 113) {
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
return;
}
dpVal = !dpVal;
Expand Down
4 changes: 4 additions & 0 deletions manualtest/test-writestorm.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ var connection = knx.Connection({
setupSwitch('1/1/6', '1/1/106').write(v);
setupSwitch('1/1/7', '1/1/107').write(v);
setupSwitch('1/1/8', '1/1/108').write(v);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
},
error: function( errmsg ) {
console.error(errmsg);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"url": "https://ekarak@bitbucket.org/ekarak/knx.js.git"
},
"scripts": {
"test": "multi-tape test/*/test-*.js"
"test": "multi-tape test/*/test-*.js",
"test-connection": "multi-tape test/*/test-connect-routing.js"
},
"license": "MIT",
"author": {
Expand Down
4 changes: 2 additions & 2 deletions src/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ FSM.prototype.read = function(grpaddr, callback) {
});
}

FSM.prototype.Disconnect = function(cb) {
this.transition("disconnecting");
FSM.prototype.Disconnect = function() {
this.transition('disconnecting');
// machina.js removeAllListeners equivalent:
// this.off();
}
Expand Down
21 changes: 16 additions & 5 deletions test/connection/test-connect-routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,33 @@
Error.stackTraceLimit = Infinity;

const knx = require('../..');
const address = require('../../src/Address.js');
const assert = require('assert');
const test = require('tape');

//
test('KNX connect routing', function(t) {
let ipAddr; // FILL THIS
let ipPort; // FILL THIS

if(!ipAddr || !ipPort) {
t.skip('No ip/port of test device')
t.end();
process.exit(0);
}

var connection = knx.Connection({
loglevel: 'trace',
loglevel: 'debug',
ipAddr,
ipPort,
handlers: {
connected: function() {
console.log('----------');
console.log('Connected!');
console.log('----------');
t.pass('connected in routing mode');
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
},
error: function() {
t.fail('error connecting');
Expand Down
5 changes: 4 additions & 1 deletion test/wiredtests/test-connect-routing-hybrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
connected: function() {
t.pass('connected in hybrid mode');
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
},
error: function(connstatus) {
t.fail('error connecting: '+connstatus);
Expand Down
2 changes: 1 addition & 1 deletion test/wiredtests/test-connect-tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
console.log('Connected!');
console.log('----------');
t.pass('connected in TUNNELING mode');
this.Disconnect();
connection.Disconnect();
},
disconnected: function() {
t.pass('disconnected in TUNNELING mode');
Expand Down
5 changes: 4 additions & 1 deletion test/wiredtests/test-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
if (counter == 4) {
t.pass('all 4 responses received');
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
}
});
// operation 1
Expand Down
5 changes: 4 additions & 1 deletion test/wiredtests/test-logotimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
timer_status.read(function(src, response) {
t.pass(util.format("**** Timer status response: %j", response));
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
});
timer_control.write(12);
}
Expand Down
5 changes: 4 additions & 1 deletion test/wiredtests/test-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
console.log("KNX response from %s: %j", src, response);
t.pass(util.format('read temperature: %s', response));
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
});
},
error: function(connstatus) {
Expand Down
5 changes: 4 additions & 1 deletion test/wiredtests/test-readstorm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ if (process.env.hasOwnProperty('WIREDTEST')) {
if (Object.keys(readback).length == options.readstorm_range) {
t.pass(util.format('readstorm: all %d datapoints accounted for', options.readstorm_range));
t.end();
process.exit(0);
connection.Disconnect();
connection.on('disconnected', () => {
process.exit(0);
})
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion typescript-sample/test-toggle-onoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function onConnected() {
dp.write(0)
await wait(2000)

connection.Disconnect()
connection.Disconnect();
}

function wait(ms: number) {
Expand Down
Loading