pigpiod - only allow send if actually connected.

This commit is contained in:
Dave Conway-Jones 2017-04-19 11:13:57 +01:00
parent a881a5c4af
commit d48644e16a
No known key found for this signature in database
GPG Key ID: 81B04231572A9A2D
2 changed files with 22 additions and 19 deletions

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-pi-gpiod",
"version": "0.0.3",
"version": "0.0.4",
"description": "A node-red node for PiGPIOd",
"dependencies" : {
"js-pigpio": "*"

View File

@ -99,6 +99,7 @@ module.exports = function(RED) {
var PiGPIO;
function inputlistener(msg) {
if (!inerror) {
if (msg.payload === "true") { msg.payload = true; }
if (msg.payload === "false") { msg.payload = false; }
var out = Number(msg.payload);
@ -120,6 +121,7 @@ module.exports = function(RED) {
}
else { node.warn(RED._("pi-gpiod:errors.invalidinput")+": "+out); }
}
}
if (node.pin !== undefined) {
PiGPIO = new Pigpio();
@ -132,6 +134,7 @@ module.exports = function(RED) {
node.retry = setTimeout(function() { doit(); }, 5000);
}
else {
inerror = false;
PiGPIO.set_mode(node.pin,PiGPIO.OUTPUT);
if (node.set) {
setTimeout(function() { PiGPIO.write(node.pin,node.level); }, 25 );