From d7e7756dcfee1dafa1e2d6566d091ff20074e646 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sat, 13 May 2017 12:46:24 +0100 Subject: [PATCH] make Pi SRF topic editable/optional --- hardware/PiSrf/package.json | 2 +- hardware/PiSrf/pisrf.html | 5 +++++ hardware/PiSrf/pisrf.js | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hardware/PiSrf/package.json b/hardware/PiSrf/package.json index 57acdf95..8285c878 100644 --- a/hardware/PiSrf/package.json +++ b/hardware/PiSrf/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pisrf", - "version" : "0.0.4", + "version" : "0.0.5", "description" : "A Node-RED node for a Raspberry Pi to use a SRF04 or SRF05 range finder", "dependencies" : { }, diff --git a/hardware/PiSrf/pisrf.html b/hardware/PiSrf/pisrf.html index df614961..af0b26cd 100644 --- a/hardware/PiSrf/pisrf.html +++ b/hardware/PiSrf/pisrf.html @@ -4,6 +4,10 @@ +
+ + +

@@ -26,6 +30,7 @@ color:"#c6dbef", defaults: { name: { value:"" }, + topic: { value:"SRF" }, pins: { value:"", required:true, validate:RED.validators.regex(/^\d+,\d+$/) } }, inputs:0, diff --git a/hardware/PiSrf/pisrf.js b/hardware/PiSrf/pisrf.js index 3f92fc68..61a827be 100644 --- a/hardware/PiSrf/pisrf.js +++ b/hardware/PiSrf/pisrf.js @@ -24,6 +24,7 @@ module.exports = function(RED) { function PiSrfNode(n) { RED.nodes.createNode(this, n); + this.topic = n.topic; this.pins = n.pins; var node = this; @@ -36,7 +37,7 @@ module.exports = function(RED) { if (RED.settings.verbose) { node.log("out: " + data + " :"); } data = data.toString().trim(); if (data.length > 0) { - node.send({topic:"SRF",payload:data}); + node.send({topic:node.topic, payload:data}); } });