forked from OpenZWave/node-openzwave-shared
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.js
46 lines (39 loc) · 974 Bytes
/
test4.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var OpenZWave = require('./lib/openzwave-shared.js');
var os = require('os');
var zwave = new OpenZWave({
ConsoleOutput: false,
Logging: false,
SaveConfiguration: false,
DriverMaxAttempts: 3,
PollInterval: 500,
SuppressValueRefresh: true,
});
function do_disconnect() {
console.log('\n\n== Driver Statistics: %j',
zwave.getDriverStatistics());
console.log('disconnecting...');
zwave.disconnect(zwp);
zwave.updateOptions({
ConsoleOutput: true,
Logging: true,
SaveConfiguration: false,
DriverMaxAttempts: 3,
PollInterval: 500,
SuppressValueRefresh: true,
});
zwave.connect(zwp);
setTimeout(function(){
zwave.disconnect(zwp);
process.exit();
}, 5000);
}
var zwavedriverpaths = {
"darwin": '/dev/cu.usbmodem1411',
"linux": '/dev/ttyACM0',
"windows": '\\\\.\\COM3'
}
var zwp = zwavedriverpaths[os.platform()];
console.log("Connecting to %s",zwp);
zwave.connect(zwp);
process.on('SIGINT', do_disconnect);
setTimeout(do_disconnect, 3000);