cool-iot – Diff between revs 2 and 5
?pathlinks?
Rev 2 | Rev 5 | |||
---|---|---|---|---|
Line -... | Line 1... | |||
- | 1 | #!/usr/bin/env nodejs |
||
1 | /////////////////////////////////////////////////////////////////////////// |
2 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2018 - License: GNU GPLv3 // |
3 | // Copyright (C) Wizardry and Steamworks 2018 - License: GNU GPLv3 // |
|
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
4 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
|
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
5 | // rights of fair usage, the disclaimer and warranty conditions. // |
|
5 | /////////////////////////////////////////////////////////////////////////// |
6 | /////////////////////////////////////////////////////////////////////////// |
|
Line 23... | Line 24... | |||
23 | |
24 | |
|
24 | COOL[i] = new Gpio(config.GPIO[i], 'out') |
25 | COOL[i] = new Gpio(config.GPIO[i], 'out') |
|
Line 25... | Line 26... | |||
25 | } |
26 | } |
|
26 | |
27 | |
|
Line 27... | Line 28... | |||
27 | // Set up logger. |
28 | // Set up logger. |
|
28 | winston.add(winston.transports.File, {filename: 'cool-iot.log'}) |
29 | winston.add(winston.transports.File, {filename: config.log}) |
|
Line 29... | Line 30... | |||
29 | |
30 | |
|
Line 37... | Line 38... | |||
37 | }) |
38 | }) |
|
Line 38... | Line 39... | |||
38 | |
39 | |
|
39 | client.on('message', function (topic, message) { |
40 | client.on('message', function (topic, message) { |
|
40 | // message is Buffer |
41 | // message is Buffer |
|
41 | message = message.toString() |
42 | message = message.toString() |
|
42 | winston.info('Received request: ' + message) |
43 | winston.info('Received message: ' + message) |
|
43 | if(!(message in config.GPIO)) { |
44 | if(!(message in config.GPIO)) { |
|
44 | winston.warn('Request to toggle unknown GPIO: ' + message) |
45 | winston.warn('Request to toggle unknown GPIO: ' + message) |
|
45 | return; |
46 | return; |