diff --git a/nodes/core/58-debug.html b/nodes/core/58-debug.html index d3d9e04e8..7f188208a 100644 --- a/nodes/core/58-debug.html +++ b/nodes/core/58-debug.html @@ -16,18 +16,20 @@ diff --git a/nodes/hardware/35-rpi-gpio-in.html b/nodes/deprecated/35-rpi-gpio-in.html similarity index 100% rename from nodes/hardware/35-rpi-gpio-in.html rename to nodes/deprecated/35-rpi-gpio-in.html diff --git a/nodes/hardware/35-rpi-gpio-in.js b/nodes/deprecated/35-rpi-gpio-in.js similarity index 100% rename from nodes/hardware/35-rpi-gpio-in.js rename to nodes/deprecated/35-rpi-gpio-in.js diff --git a/nodes/hardware/35-rpi-gpio-out.html b/nodes/deprecated/35-rpi-gpio-out.html similarity index 100% rename from nodes/hardware/35-rpi-gpio-out.html rename to nodes/deprecated/35-rpi-gpio-out.html diff --git a/nodes/hardware/35-rpi-gpio-out.js b/nodes/deprecated/35-rpi-gpio-out.js similarity index 100% rename from nodes/hardware/35-rpi-gpio-out.js rename to nodes/deprecated/35-rpi-gpio-out.js diff --git a/nodes/hardware/36-rpi-gpio.html b/nodes/hardware/36-rpi-gpio.html new file mode 100644 index 000000000..9fe873055 --- /dev/null +++ b/nodes/hardware/36-rpi-gpio.html @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + diff --git a/nodes/hardware/36-rpi-gpio.js b/nodes/hardware/36-rpi-gpio.js new file mode 100644 index 000000000..7ae3ffb21 --- /dev/null +++ b/nodes/hardware/36-rpi-gpio.js @@ -0,0 +1,141 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var RED = require("../../red/red"); +var util = require("util"); +var exec = require('child_process').exec; +var fs = require('fs'); + +if (!fs.existsSync("/usr/local/bin/gpio")) { + exec("cat /proc/cpuinfo | grep BCM27",function(err,stdout,stderr) { + if (stdout.indexOf('BCM27') > -1) { + util.log('[36-rpi-gpio.js] Error: Cannot find Wiring-Pi "gpio" command'); + } + // else not on a Pi so don't worry anyone with needless messages. + }); + return; +} + +// Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) +var pintable = { +// Physical : WiringPi + "7":"7", + "11":"0", + "12":"1", + "13":"2", + "15":"3", + "16":"4", + "18":"5", + "22":"6" +} +var tablepin = { +// WiringPi : Physical + "7":"7", + "0":"11", + "1":"12", + "2":"13", + "3":"15", + "4":"16", + "5":"18", + "6":"22" +} + +function GPIOInNode(n) { + RED.nodes.createNode(this,n); + this.buttonState = -1; + this.pin = pintable[n.pin]; + this.intype = n.intype; + var node = this; + + if (this.pin) { + exec("gpio mode "+node.pin+" "+node.intype, function(err,stdout,stderr) { + if (err) node.error(err); + else { + node._interval = setInterval( function() { + exec("gpio read "+node.pin, function(err,stdout,stderr) { + if (err) node.error(err); + else { + if (node.buttonState !== Number(stdout)) { + var previousState = node.buttonState; + node.buttonState = Number(stdout); + if (previousState !== -1) { + var msg = {topic:"pi/"+tablepin[node.pin], payload:node.buttonState}; + node.send(msg); + } + } + } + }); + }, 250); + } + }); + } + else { + this.error("Invalid GPIO pin: "+this.pin); + } +} + +function GPIOOutNode(n) { + RED.nodes.createNode(this,n); + this.pin = pintable[n.pin]; + var node = this; + + if (this.pin) { + process.nextTick(function() { + exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) { + if (err) node.error(err); + else { + node.on("input", function(msg) { + if (msg.payload === "true") msg.payload = true; + if (msg.payload === "false") msg.payload = false; + var out = Number(msg.payload); + if ((out == 0)|(out == 1)) { + exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) { + if (err) node.error(err); + }); + } + else node.warn("Invalid input - not 0 or 1"); + }); + } + }); + }); + } + else { + this.error("Invalid GPIO pin: "+this.pin); + } +} + +exec("gpio reset",function(err,stdout,stderr) { + if (err) { + util.log('[36-rpi-gpio.js] Error: "gpio reset" command failed for some reason.'); + } + exec("gpio load spi",function(err,stdout,stderr) { + if (err) { + util.log('[36-rpi-gpio.js] Error: "gpio load spi" command failed for some reason.'); + } + + RED.nodes.registerType("rpi-gpio in",GPIOInNode); + RED.nodes.registerType("rpi-gpio out",GPIOOutNode); + + GPIOInNode.prototype.close = function() { + clearInterval(this._interval); + } + + GPIOOutNode.prototype.close = function() { + exec("gpio mode "+this.pin+" in"); + } + + }); +}); diff --git a/nodes/hardware/76-blinkstick.js b/nodes/hardware/76-blinkstick.js index 10eb9913c..bf5d72027 100644 --- a/nodes/hardware/76-blinkstick.js +++ b/nodes/hardware/76-blinkstick.js @@ -25,7 +25,7 @@ Object.size = function(obj) { function BlinkStick(n) { RED.nodes.createNode(this,n); - var p1 = /^\#[A-Za-z0-9]{6}$/ + var p1 = /^\#[A-Fa-f0-9]{6}$/ var p2 = /[0-9]+,[0-9]+,[0-9]+/ this.led = blinkstick.findFirst(); // maybe try findAll() (one day) var node = this; @@ -33,21 +33,23 @@ function BlinkStick(n) { this.on("input", function(msg) { if (msg != null) { if (Object.size(node.led) !== 0) { - if (p2.test(msg.payload)) { - var rgb = msg.payload.split(","); - node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); - } - else { - try { + try { + if (p2.test(msg.payload)) { + var rgb = msg.payload.split(","); + node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); + } + else { node.led.setColor(msg.payload); } - catch (err) { - node.warn("Incorrect format: "+msg.payload); - } + } + catch (err) { + node.warn("BlinkStick missing ?"); + node.led = blinkstick.findFirst(); } } else { node.warn("No BlinkStick found"); + node.led = blinkstick.findFirst(); } } }); diff --git a/nodes/hardware/77-blink1.js b/nodes/hardware/77-blink1.js index 95257c211..236683ed9 100644 --- a/nodes/hardware/77-blink1.js +++ b/nodes/hardware/77-blink1.js @@ -23,7 +23,7 @@ function Blink1Node(n) { var node = this; try { - var p1 = /^\#[A-Za-z0-9]{6}$/ + var p1 = /^\#[A-Fa-f0-9]{6}$/ var p2 = /[0-9]+,[0-9]+,[0-9]+/ this.on("input", function(msg) { if (blink1) { @@ -53,7 +53,7 @@ function Blink1Node(n) { var blink1 = new Blink1.Blink1(); } catch(e) { - node.error("no Blink1 found"); + node.error("No Blink1 found"); } } diff --git a/nodes/hardware/78-ledborg.html b/nodes/hardware/78-ledborg.html new file mode 100644 index 000000000..e97da1b0a --- /dev/null +++ b/nodes/hardware/78-ledborg.html @@ -0,0 +1,50 @@ + + + + + + + diff --git a/nodes/hardware/78-ledborg.js b/nodes/hardware/78-ledborg.js new file mode 100644 index 000000000..80f6e3167 --- /dev/null +++ b/nodes/hardware/78-ledborg.js @@ -0,0 +1,53 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var RED = require("../../red/red"); +var util = require('util'); +var fs = require('fs'); + +// check if /dev/ledborg exists - if not then don't even show the node. +if (!fs.existsSync("/dev/ledborg")) { + util.log("[78-ledborg.js] Error: PiBorg hardware : LedBorg not found"); + return; +} + +function LedBorgNode(n) { + RED.nodes.createNode(this,n); + var p1 = /[0-2][0-2][0-2]/ + var p2 = /^\#[A-Fa-f0-9]{6}$/ + var node = this; + + this.on("input", function(msg) { + if (p1.test(msg.payload)) { + fs.writeFile('/dev/ledborg', msg.payload, function (err) { + if (err) node.warn(msg.payload+" : No LedBorg found"); + }); + } + if (p2.test(msg.payload)) { + var r = Math.floor(parseInt(msg.payload.slice(1,3),16)/88).toString(); + var g = Math.floor(parseInt(msg.payload.slice(3,5),16)/88).toString(); + var b = Math.floor(parseInt(msg.payload.slice(5),16)/88).toString(); + fs.writeFile('/dev/ledborg', r+g+b, function (err) { + if (err) node.warn(r+g+b+" : No LedBorg found"); + }); + } + else { + node.warn("Invalid LedBorg colour code"); + } + }); +} + +RED.nodes.registerType("ledborg",LedBorgNode); diff --git a/nodes/io/21-httpin.js b/nodes/io/21-httpin.js index d7b676dd2..b0bbd96e3 100644 --- a/nodes/io/21-httpin.js +++ b/nodes/io/21-httpin.js @@ -37,15 +37,17 @@ function HTTPIn(n) { } } +RED.nodes.registerType("http in",HTTPIn); HTTPIn.prototype.close = function() { - var routes = redUI.app.routes[this.method]; + console.log(RED.app.routes[this.method]); + var routes = RED.app.routes[this.method]; for (var i in routes) { if (routes[i].path == this.url) { routes.splice(i,1); break; } } + console.log(RED.app.routes[this.method]); } -RED.nodes.registerType("http in",HTTPIn); diff --git a/nodes/io/31-tcpin.html b/nodes/io/31-tcpin.html index d1f3b7f67..4257d4a50 100644 --- a/nodes/io/31-tcpin.html +++ b/nodes/io/31-tcpin.html @@ -16,22 +16,36 @@ diff --git a/nodes/io/31-tcpin.js b/nodes/io/31-tcpin.js index f548ebfe2..78b7ab731 100644 --- a/nodes/io/31-tcpin.js +++ b/nodes/io/31-tcpin.js @@ -15,7 +15,7 @@ **/ var RED = require("../../red/red"); -var reConnect = RED.settings.socketReconnectTime||10000; +var reconnectTime = RED.settings.socketReconnectTime||10000; var net = require('net'); function TcpIn(n) { @@ -23,76 +23,126 @@ function TcpIn(n) { this.host = n.host; this.port = n.port * 1; this.topic = n.topic; + this.stream = (!n.datamode||n.datamode=='stream'); /* stream,single*/ + this.datatype = n.datatype||'buffer'; /* buffer,utf8,base64 */ + this.newline = (n.newline||"").replace("\\n","\n").replace("\\r","\r"); this.base64 = n.base64; - this.server = n.server; + this.server = (typeof n.server == 'boolean')?n.server:(n.server == "server"); + this.closing = false; var node = this; - + if (!node.server) { + var buffer = null; var client; - var to; - + var reconnectTimeout; function setupTcpClient() { - node.log('connecting to port '+node.port); + node.log("connecting to "+node.host+":"+node.port); client = net.connect(node.port, node.host, function() { - node.log("input connected to "+node.host+":"+node.port); + buffer = (node.datatype == 'buffer')? new Buffer(0):""; + node.log("connected to "+node.host+":"+node.port); }); - + client.on('data', function (data) { - var msg; - if (node.base64) { msg = { topic:node.topic, payload:new Buffer(data).toString('base64') }; } - else { msg = {topic:node.topic, payload:data}; } - node.send(msg); + if (node.datatype != 'buffer') { + data = data.toString(node.datatype); + } + if (node.stream) { + if ((typeof data) === "string" && node.newline != "") { + buffer = buffer+data; + var parts = buffer.split(node.newline); + for (var i = 0;i 0)) { + var msg = {topic:node.topic,payload:buffer}; + node.send(msg); + buffer = null; + } }); client.on('close', function() { - client.destroy(); - node.log('closed'); - to = setTimeout(setupTcpClient, reConnect); + node.log("connection lost to "+node.host+":"+node.port); + if (!node.closing) { + reconnectTimeout = setTimeout(setupTcpClient, reconnectTime); + } }); client.on('error', function(err) { - node.log('error : '+err); - //to = setTimeout(setupTcpClient, reConnect); + node.log(err); }); } setupTcpClient(); this._close = function() { + this.closing = true; client.end(); - clearTimeout(to); - node.log('input stopped'); + clearTimeout(reconnectTimeout); } - } - else { + } else { var server = net.createServer(function (socket) { - var buffer = null; - socket.on('data', function (chunk) { - //if (buffer == null) { - // buffer = chunk; - //} else { - //buffer = Buffer.concat([buffer,chunk]); - var msg = {topic:node.topic, payload:chunk, fromip:socket.remoteAddress+':'+socket.remotePort}; - node.send(msg); - //} - }); - socket.on('end', function() { - var msg = {topic:node.topic, payload:buffer, fromip:socket.remoteAddress+':'+socket.remotePort}; - node.send(msg); - }); + var buffer = (node.datatype == 'buffer')? new Buffer(0):""; + socket.on('data', function (data) { + if (node.datatype != 'buffer') { + data = data.toString(node.datatype); + } + + if (node.stream) { + if ((typeof data) === "string" && node.newline != "") { + buffer = buffer+data; + var parts = buffer.split(node.newline); + for (var i = 0;i 0)) { + var msg = {topic:node.topic,payload:buffer}; + node.send(msg); + buffer = null; + } + }); + socket.on('error',function(err) { + node.log(err); + }); }); server.listen(node.port); - node.log('socket input on port '+node.port); - + node.log('listening on port '+node.port); + this._close = function() { + this.closing = true; server.close(); - node.log('socket input stopped'); + node.log('stopped listening on port '+node.port); } } - + } RED.nodes.registerType("tcp in",TcpIn); diff --git a/nodes/io/31-tcpout.html b/nodes/io/31-tcpout.html index d8febe216..f0457fb87 100644 --- a/nodes/io/31-tcpout.html +++ b/nodes/io/31-tcpout.html @@ -16,34 +16,37 @@ diff --git a/nodes/io/31-tcpout.js b/nodes/io/31-tcpout.js index c7bb30a47..1a626736b 100644 --- a/nodes/io/31-tcpout.js +++ b/nodes/io/31-tcpout.js @@ -15,7 +15,7 @@ **/ var RED = require("../../red/red"); -var reConnect = RED.settings.socketReconnectTime||10000; +var reconnectTime = RED.settings.socketReconnectTime||10000; var net = require('net'); function TcpOut(n) { @@ -25,67 +25,93 @@ function TcpOut(n) { this.base64 = n.base64; this.beserver = n.beserver; this.name = n.name; + this.closing = false; var node = this; - if (!node.beserver) { - var client = new net.Socket(); - var to; - + if (!node.beserver||node.beserver=="client") { + var reconnectTimeout; + var client = null; + var connected = false; + function setupTcpClient() { - client.connect(node.port, node.host, function() { - node.log("output connected to "+node.host+":"+node.port); + node.log("connecting to "+node.host+":"+node.port); + client = net.connect(node.port, node.host, function() { + connected = true; + node.log("connected to "+node.host+":"+node.port); }); - + client.on('error', function (err) { - node.error('error : '+err); - to = setTimeout(setupTcpClient, reConnect); + node.log('error : '+err); }); - + client.on('end', function (err) { - node.log("output disconnected"); - to = setTimeout(setupTcpClient, reConnect); }); - + client.on('close', function() { - client.destroy(); - node.log('closed'); - to = setTimeout(setupTcpClient, reConnect); - }); - - node.on("input", function(msg) { - if (msg.payload != null) { - if (node.base64) { client.write(new Buffer(msg.payload,'base64')); } - else { client.write(msg.payload);} - } + node.log("connection lost to "+node.host+":"+node.port); + connected = false; + client.destroy(); + if (!node.closing) { + reconnectTimeout = setTimeout(setupTcpClient,reconnectTime); + } }); } setupTcpClient(); - + + + node.on("input", function(msg) { + if (connected && msg.payload != null) { + if (Buffer.isBuffer(msg.payload)) { + client.write(msg.payload); + } else if (typeof msg.payload === "string" && node.base64) { + client.write(new Buffer(msg.payload,'base64')); + } else { + client.write(new Buffer(""+msg.payload)); + } + } + }); + + this._close = function() { + this.closing = true; client.end(); - clearTimeout(to); - node.log('output stopped'); + clearTimeout(reconnectTimeout); } } else { + var connectedSockets = []; var server = net.createServer(function (socket) { - socket.on("connect",function() { - node.log("Connection from "+socket.remoteAddress); - }); - node.on("input", function(msg) { - if (msg.payload != null) { - if (node.base64) { socket.write(new Buffer(msg.payload,'base64')); } - else { socket.write(msg.payload);} - } - }); + var remoteDetails = socket.remoteAddress+":"+socket.remotePort; + node.log("connection from "+remoteDetails); + connectedSockets.push(socket); + socket.on('close',function() { + node.log("connection closed from "+remoteDetails); + connectedSockets.splice(connectedSockets.indexOf(socket),1); + }); }); + node.on("input", function(msg) { + if (msg.payload != null) { + var buffer; + if (Buffer.isBuffer(msg.payload)) { + buffer = msg.payload; + } else if (typeof msg.payload === "string" && node.base64) { + buffer = new Buffer(msg.payload,'base64'); + } else { + buffer = new Buffer(""+msg.payload); + } + for (var i = 0; i + + + + + + + + + + + + + + + + + + diff --git a/nodes/storage/67-leveldb.js b/nodes/storage/67-leveldb.js new file mode 100644 index 000000000..e8923d750 --- /dev/null +++ b/nodes/storage/67-leveldb.js @@ -0,0 +1,90 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var RED = require("../../red/red"); +var lvldb = require('leveldb'); + +function LevelNode(n) { + RED.nodes.createNode(this,n); + this.dbname = n.db; + lvldb.open(this.dbname, { create_if_missing: true }, onOpen); + var node = this; + function onOpen(err, db) { + if (err) node.error(err); + node.db = db; + } +} +RED.nodes.registerType("leveldbase",LevelNode); + + +function LevelDBNodeIn(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.op = n.op; + this.levelConfig = RED.nodes.getNode(this.level); + + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + node.levelConfig.db.get(msg.topic, function(err, value) { + if (err) node.error(err); + msg.payload = JSON.parse(value); + delete msg.cmd; + node.send(msg); + }); + } + else { + if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); + } + }); + } + else { + this.error("LevelDB database name not configured"); + } +} +RED.nodes.registerType("leveldb in",LevelDBNodeIn); + + +function LevelDBNodeOut(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.levelConfig = RED.nodes.getNode(this.level); + + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + console.log(msg); + if (msg.payload === null) { + node.levelConfig.db.del(msg.topic); + } + else { + node.levelConfig.db.put(msg.topic, JSON.stringify(msg.payload), function(err) { + if (err) node.error(err); + }); + } + } + else { + if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); + } + }); + } + else { + this.error("LevelDB database name not configured"); + } +} +RED.nodes.registerType("leveldb out",LevelDBNodeOut); diff --git a/public/icons/leveldb.png b/public/icons/leveldb.png new file mode 100644 index 000000000..55760c7dc Binary files /dev/null and b/public/icons/leveldb.png differ diff --git a/public/red/ui/editor.js b/public/red/ui/editor.js index 40deb4feb..fc85f58cc 100644 --- a/public/red/ui/editor.js +++ b/public/red/ui/editor.js @@ -96,7 +96,7 @@ RED.editor = function() { valid = value !== ""; } if (valid && "validate" in node._def.defaults[property]) { - valid = node._def.defaults[property].validate(value); + valid = node._def.defaults[property].validate.call(node,value); } if (valid && node._def.defaults[property].type && RED.nodes.getType(node._def.defaults[property].type)) { valid = (value != "_ADD_"); diff --git a/public/red/ui/notifications.js b/public/red/ui/notifications.js index e0e26bc04..3150046ed 100644 --- a/public/red/ui/notifications.js +++ b/public/red/ui/notifications.js @@ -16,14 +16,22 @@ RED.notify = function() { var currentNotifications = []; var c = 0; - return function(msg,type) { - while (currentNotifications.length > 4) { - var n = currentNotifications[0]; - window.clearTimeout(n.id); - n.slideup(); + return function(msg,type,fixed) { + if (currentNotifications.length > 4) { + var ll = currentNotifications.length; + for (var i = 0;ll > 4 && i 0) { + var i = missingTypes.indexOf(type); + if (i != -1) { + missingTypes.splice(i,1); + util.log("[red] Missing type registered: "+type); + } + if (missingTypes.length == 0) { + parseConfig(); + } + } +}); + + module.exports.getNode = function(nid) { return registry.get(nid); } -module.exports.parseConfig = function(conf) { - +module.exports.setConfig = function(conf) { + if (activeConfig&&activeConfig.length > 0) { + util.log("[red] Stopping flows"); + } registry.clear(); + activeConfig = conf; + parseConfig(); +} +var parseConfig = function() { + + missingTypes = []; + for (var i in activeConfig) { + var type = activeConfig[i].type; + var nt = node_type_registry.get(type); + if (!nt && missingTypes.indexOf(type) == -1) { + missingTypes.push(type); + } + }; + if (missingTypes.length > 0) { + util.log("[red] Waiting for missing types to be registered:"); + for (var i in missingTypes) { + util.log("[red] - "+missingTypes[i]); + } + + return; + } + + util.log("[red] Starting flows"); events.emit("nodes-starting"); - for (var i in conf) { + for (var i in activeConfig) { var nn = null; - var nt = node_type_registry.get(conf[i].type); + var nt = node_type_registry.get(activeConfig[i].type); if (nt) { try { - nn = new nt(conf[i]); + nn = new nt(activeConfig[i]); } catch (err) { - util.log("[red] "+conf[i].type+" : "+err); + util.log("[red] "+activeConfig[i].type+" : "+err); } } // console.log(nn); if (nn == null) { - util.log("[red] unknown type: "+conf[i].type); + util.log("[red] unknown type: "+activeConfig[i].type); } } diff --git a/red/server.js b/red/server.js index 6537711ac..4475e013e 100644 --- a/red/server.js +++ b/red/server.js @@ -60,7 +60,7 @@ function createServer(_server,settings) { if(err) { util.log(err); } else { - redNodes.parseConfig(JSON.parse(fullBody)); + redNodes.setConfig(JSON.parse(fullBody)); } }); }); @@ -79,13 +79,12 @@ function createServer(_server,settings) { util.log('or any other errors are resolved'); util.log("------------------------------------------"); - util.log("[red] Loading workspace flow : "+rulesfile); - fs.exists(rulesfile, function (exists) { if (exists) { + util.log("[red] Loading workspace flow : "+rulesfile); fs.readFile(rulesfile,'utf8',function(err,data) { - redNodes.parseConfig(JSON.parse(data)); + redNodes.setConfig(JSON.parse(data)); }); } }); diff --git a/settings.js b/settings.js index f4cc69269..e3e76d4a3 100644 --- a/settings.js +++ b/settings.js @@ -17,6 +17,7 @@ module.exports = { uiPort: 1880, mqttReconnectTime: 15000, serialReconnectTime: 15000, + debugMaxLength: 1000, // You can protect the user interface with a userid and password by using the following property // the password must be an md5 hash eg.. 5f4dcc3b5aa765d61d8327deb882cf99 ('password') @@ -33,7 +34,7 @@ module.exports = { // key: fs.readFileSync('privatekey.pem'), // cert: fs.readFileSync('certificate.pem') //}, - + // Anything in this hash is globally available to all functions. // It is accessed as context.global. // eg: