Remove deprecated nodes

As announced here https://groups.google.com/forum/#!topic/node-red/-2nG6nKaxFI
This commit is contained in:
Nick O'Leary 2014-04-16 22:21:50 +01:00
parent fa275646a1
commit 0a2dab67c7
10 changed files with 0 additions and 848 deletions

View File

@ -1,69 +0,0 @@
<!--
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.
-->
<script type="text/x-red" data-template-name="socket in">
<div class="form-row">
<label for="node-input-transport"><i class="icon-tasks"></i> Type</label>
<select type="text" id="node-input-transport" style="width: 150px;">
<option value="http">http listen</option>
<option value="tcp">tcp server</option>
<!-- <option value="tcpc">tcp client</option> -->
<option value="udp">udp socket</option>
</select>
</div>
<div class="form-row">
<label for="node-input-port"><i class="icon-random"></i> Port</label>
<input type="text" id="node-input-port" placeholder="Port">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Tip: sends the received data as a Buffer object.</div>
</script>
<script type="text/x-red" data-help-name="socket in">
<p>Provides a input node for http, tcp or udp sockets. Topic is optional. These are server like sockets.</p>
<p>The TCP and UDP sockets produce a <i>BUFFER</i> object msg.payload and NOT a String. If you need a String then use .toString() on msg.payload in your next function block.</p>
<p>TCP and UDP sockets also provide <b>msg.fromip</b> of the form ipaddress:port</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('socket in',{
category: 'deprecated',
color:"Silver",
defaults: {
name: {value:""},
topic: {value:""},
port: {value:"",required:true},
transport: {value:"tcp",required:true}
},
inputs:0,
outputs:1,
icon: "bridge-dash.png",
label: function() {
return this.name||this.topic||("socket "+this.transport+":"+this.port);
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -1,152 +0,0 @@
/**
* 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(process.env.NODE_RED_HOME+"/red/red");
function SocketIn(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated - will be removed in a future release");
this.port = n.port;
this.topic = n.topic;
this.trans = (n.transport||n.trans||"").toLowerCase();
var node = this;
if (this.trans == "http") {
var http = require('http');
var server = http.createServer(function (req, res) {
//node.log("http "+req.url);
var msg = {topic:node.topic,payload:req.url.slice(1)};
node.send(msg);
res.writeHead(304, {'Content-Type': 'text/plain'});
res.end('\n');
}).listen(node.port);
server.on('error', function (e) {
if (e.code == 'EADDRINUSE') {
setTimeout(node.error('TCP port is already in use - please reconfigure socket.'),250);
}
else { console.log(e); }
server = null;
});
node.log('http listener at http://127.0.0.1:'+node.port+'/');
this._close = function() {
if (server) server.close();
node.log('http listener stopped');
}
}
if (this.trans == "tcp") {
var net = require('net');
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]);
}
});
socket.on('end', function() {
var msg = {topic:node.topic, payload:buffer, fromip:socket.remoteAddress+':'+socket.remotePort};
node.send(msg);
});
});
server.on('error', function (e) {
if (e.code == 'EADDRINUSE') {
setTimeout(node.error('TCP port is already in use - please reconfigure socket.'),250);
}
else { console.log(e); }
server = null;
});
server.listen(node.port);
node.log('tcp listener on port :'+node.port);
this._close = function() {
if (server) server.close();
node.log('tcp listener stopped');
}
}
if (this.trans == "tcpc") {
var net = require('net');
var client;
var to;
function setupTcpClient() {
node.log('tcpc connecting to port :'+node.port);
client = net.connect({port: node.port}, function() {
node.log("tcpc connected");
});
client.on('data', function (data) {
var msg = {topic:node.topic, payload:data};
node.send(msg);
});
client.on('end', function() {
node.log("tcpc socket ended");
});
client.on('close', function() {
node.log('tcpc socket closed');
to = setTimeout(setupTcpClient, 10000); //Try to reconnect
});
client.on('error', function() {
node.log('tcpc socket error');
client = null;
to = setTimeout(setupTcpClient, 10000); //Try to reconnect
});
}
setupTcpClient();
this._close = function() {
if (client) client.end();
//client.destroy();
clearTimeout(to);
node.log('tcpc stopped client');
}
setupTcpClient();
}
if (this.trans == "udp") {
var dgram = require('dgram');
var server = dgram.createSocket('udp4');
server.on('listening', function () {
var address = server.address();
node.log('udp listener at ' + address.address + ":" + address.port);
});
server.on('message', function (message, remote) {
var msg = {topic:node.topic,payload:message,fromip:remote.address+':'+remote.port};
node.send(msg);
});
server.on('error', function (e) {
console.log(e);
server = null;
});
server.bind(node.port);
this._close = function() {
if (server) server.close();
node.log('udp listener stopped');
}
}
}
RED.nodes.registerType("socket in",SocketIn);
SocketIn.prototype.close = function() {
this._close();
}

View File

@ -1,66 +0,0 @@
<!--
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.
-->
<script type="text/x-red" data-template-name="socket out">
<div class="form-row">
<label for="node-input-host"><i class="icon-bookmark"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost" style="width: 40%;" >
<label for="node-input-port" style="margin-left: 10px; width: 35px;"> Port</label>
<input type="text" id="node-input-port" placeholder="Port" style="width: 45px">
</div>
<div class="form-row">
<label for="node-input-transport"><i class="icon-tasks"></i> Type</label>
<select type="text" id="node-input-transport" style="width: 150px;">
<option value="http">http</option>
<option value="tcp">tcp</option>
<option value="udp">udp</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="socket out">
<p>Provides a choice of http, tcp or udp output connections. All connect, send their <b>msg.payload</b> and disconnect.</p>
<p>To use broadcast select udp and set the host to be either the subnet broadcast address required or 255.255.255.255</p>
<p>If you need a response from an http request use the httpget node instead.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('socket out',{
category: 'deprecated',
color:"Silver",
defaults: {
host: {value:"127.0.0.1",required:true},
port: {value:"",required:true},
name: {value:""},
transport: {value:"tcp",required:true}
},
inputs:1,
outputs:0,
icon: "bridge-dash.png",
align: "right",
label: function() {
return this.name||this.topic||("socket "+this.transport+":"+this.port);
},
labelStyle: function() {
return (this.name||!this.topic)?"node_label_italic":"";
}
});
</script>

View File

@ -1,65 +0,0 @@
/**
* 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(process.env.NODE_RED_HOME+"/red/red");
function SocketOut(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated - will be removed in a future release");
this.host = n.host;
this.port = n.port * 1;
this.name = n.name;
this.trans = n.transport||n.trans||"";
var node = this;
this.on("input", function(msg) {
if (msg != null) {
if (this.trans == "http") {
var http = require("http");
http.get(msg.payload, function(res) {
node.log("http : response : " + res.statusCode);
}).on('error', function(e) {
node.error("http : error : " + e.message);
});
}
if (this.trans == "tcp") {
var net = require('net');
var client = new net.Socket();
client.on('error', function (err) {
node.error('tcp : '+err);
});
client.connect(this.port, this.host, function() {
try { client.end(msg.payload); }
catch (e) { node.error(e); }
});
}
if (this.trans == "udp") {
var dgram = require('dgram');
var sock = dgram.createSocket('udp4'); // only use ipv4 for now
sock.bind(this.port); // have to bind before you can enable broadcast...
sock.setBroadcast(true); // turn on broadcast
var buf = new Buffer(msg.payload);
sock.send(buf, 0, buf.length, this.port, this.host, function(err, bytes) {
if (err) node.error("udp : "+err);
//util.log('[socket out] udp :' +bytes);
sock.close();
});
}
}
});
var node = this;
}
RED.nodes.registerType("socket out",SocketOut);

View File

@ -1,131 +0,0 @@
<!--
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.
-->
<!-- The Input Node -->
<script type="text/x-red" data-template-name="multicast in">
<div class="form-row">
<label for="node-input-group"><i class="icon-tasks"></i> Group</label>
<input type="text" id="node-input-group" placeholder="225.0.18.83" style="width: 40%;">
<label for="node-input-port" style="margin-left: 10px; width: 35px;"> Port</label>
<input type="text" id="node-input-port" placeholder="Port" style="width: 45px">
</div>
<div class="form-row">
<label for="node-input-iface"><i class="icon-globe"></i> Interface</label>
<input type="text" id="node-input-iface" placeholder="eth0">
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-base64" placeholder="base64" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-base64" style="width: 70%;">Base64 encode payload ?</label>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Tip: sends the received data as a Buffer object (not a String).<br/>Make sure your firewall will allow the data in.</div>
</script>
<script type="text/x-red" data-help-name="multicast in">
<p>A multicast udp input node, that produces a <b>msg.payload</b> containing a <i>BUFFER</i> object and NOT a String.</p>
<p>If you need a String then use <i>.toString()</i> on <b>msg.payload</b> in your next function block.</p>
<p>It also provides <b>msg.fromip</b> of the form ipaddress:port .</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('multicast in',{
category: 'deprecated',
color:"Silver",
defaults: {
name: {value:""},
group: {value:"",required:true},
host: {value:""},
iface: {value:""},
port: {value:"",required:true,validate:RED.validators.number()},
base64: {value:false,required:true},
multicast: {value:"true"}
},
inputs:0,
outputs:1,
icon: "bridge-dash.png",
label: function() {
if ((this.group!="") & (this.port!="")) {
return this.name||(this.group+":"+this.port);
}
else { return "multicast in"; }
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>
<!-- The Output Node -->
<script type="text/x-red" data-template-name="multicast out">
<div class="form-row">
<label for="node-input-group"><i class="icon-tasks"></i> Group</label>
<input type="text" id="node-input-group" placeholder="225.0.18.83" style="width: 40%;">
<label for="node-input-port" style="margin-left: 10px; width: 35px;"> Port</label>
<input type="text" id="node-input-port" placeholder="Port" style="width: 45px">
</div>
<div class="form-row">
<label for="node-input-iface"><i class="icon-globe"></i> Interface</label>
<input type="text" id="node-input-iface" placeholder="eth0">
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-base64" placeholder="base64" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-base64" style="width: 70%;">Decode Base64 encoded payload ?</label>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="multicast out">
<p>This node sends <b>msg.payload</b> to the designated multicast group and port.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('multicast out',{
category: 'deprecated',
color:"Silver",
defaults: {
name: {value:""},
group: {value:"",required:true},
host: {value:""},
iface: {value:""},
port: {value:"",required:true,validate:RED.validators.number()},
base64: {value:false,required:true},
multicast: {value:"true"}
},
inputs:1,
outputs:0,
icon: "bridge-dash.png",
align: "right",
label: function() {
if ((this.group!="") & (this.port!="")) {
return this.name||(this.group+":"+this.port);
}
else { return "multicast out"; }
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -1,119 +0,0 @@
/**
* 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(process.env.NODE_RED_HOME+"/red/red");
var dgram = require('dgram');
// The Input Node
function MCastIn(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated - will be removed in a future release");
this.group = n.group;
this.port = n.port;
this.host = n.host || null;
this.base64 = n.base64;
this.iface = n.iface || null;
this.multicast = n.multicast;
var node = this;
var server = dgram.createSocket('udp4');
server.on("error", function (err) {
console.log("udp listener error:\n" + err.stack);
server.close();
});
server.on('message', function (message, remote) {
var msg;
if (node.base64) { msg = { payload:message.toString('base64'), fromip:remote.address+':'+remote.port }; }
else { msg = { payload:message, fromip:remote.address+':'+remote.port }; }
node.send(msg);
});
server.on('listening', function () {
var address = server.address();
node.log('udp listener at ' + address.address + ":" + address.port);
if (node.multicast) {
server.setBroadcast(true)
server.setMulticastTTL(128);
server.addMembership(node.group,node.iface);
node.log("udp multicast group "+node.group);
}
});
//server.bind(node.port,node.host);
server.bind(node.port,node.host);
this._close = function() {
server.close();
node.log('udp listener stopped');
}
}
MCastIn.prototype.close = function() {
this._close();
}
RED.nodes.registerType("multicast in",MCastIn);
// The Output Node
function MCastOut(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated");
this.group = n.group;
this.port = n.port;
this.host = n.host || null;
this.base64 = n.base64;
this.iface = n.iface || null;
this.multicast = n.multicast;
var node = this;
var sock = dgram.createSocket('udp4'); // only use ipv4 for now
sock.bind(node.port); // have to bind before you can enable broadcast...
sock.setBroadcast(true); // turn on broadcast
sock.setMulticastTTL(128);
sock.addMembership(node.group,node.iface); // Add to the multicast group
node.log('udp multicaster ready on '+node.group+":"+node.port);
node.on("input", function(msg) {
if (msg.payload != null) {
console.log("MCast:",msg.payload);
var message;
if (node.base64) {
message = new Buffer(msg.payload,'base64');
}
else {
message = new Buffer(msg.payload);
}
sock.send(message, 0, message.length, node.port, node.group, function(err, bytes) {
if (err) node.error("udp : "+err);
//util.log('[socket out] udp :' +bytes);
});
}
});
this._close = function() {
sock.close();
node.log('udp multicaster stopped');
}
}
RED.nodes.registerType("multicast out",MCastOut);
MCastOut.prototype.close = function() {
this._close();
}

View File

@ -1,69 +0,0 @@
<!--
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.
-->
<script type="text/x-red" data-template-name="rpi-gpio in">
<div class="form-row">
<label for="node-input-pin"><i class="icon-asterisk"></i> Pin</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="7">7</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="18">18</option>
<option value="22">22</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-resistor"><i class=" icon-resize-full"></i> Resistor?</label>
<select type="text" id="node-input-resistor" style="width: 150px;">
<option value="no">no</option>
<option value="pullup">pullup</option>
<option value="pulldown">pulldown</option>
</select>
</div>
<div class="form-tips">Tip: if pull up/down resistor is selected, the <code>gpio-admin</code> command <em>must</em> be used
to do the actual enabling. If 'no' resistor is selected, nothing further needs to be done
to use this node. See <code>man gpio-admin</code> for more details.</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('rpi-gpio in',{
category: 'deprecated',
color:"#c6dbef",
defaults: {
name: { value:""},
resistor: { value: "no"},
pin: {value:"",required:true},
},
inputs:0,
outputs:1,
icon: "rpi.png",
label: function() {
return this.name||"Pin: "+this.pin;
//+(this.resistor == "no"?"":" ("+(this.resistor=="pullup"?"":"&darr;")+")");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -1,70 +0,0 @@
/**
* 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(process.env.NODE_RED_HOME+"/red/red");
var gpio = require("pi-gpio");
function GPIOInNode(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated - will be removed in a future release");
this.buttonState = -1;
this.pin = n.pin;
this.resistor = n.resistor;
var node = this;
if (this.pin) {
var setupPin = function(err) {
if (err) {
node.error(err);
} else {
node._interval = setInterval(function(){
gpio.read(node.pin, function(err, value) {
if(err){
node.error(err);
} else{
if(node.buttonState !== value){
var previousState = node.buttonState;
node.buttonState = value;
if (previousState !== -1) {
var msg = {payload:node.buttonState};
node.send(msg);
}
}
}
});
}, 50);
}
};
if (this.resistor == "no") {
gpio.open(this.pin,"input",setupPin());
} else {
// Assume enabled externally via gpio-admin
setupPin();
}
} else {
this.error("Invalid GPIO pin: "+this.pin);
}
}
RED.nodes.registerType("rpi-gpio in",GPIOInNode);
GPIOInNode.prototype.close = function() {
clearInterval(this._interval);
if (this.resistor == "no") {
gpio.close(this.pin);
}
}

View File

@ -1,59 +0,0 @@
<!--
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.
-->
<script type="text/x-red" data-template-name="rpi-gpio out">
<div class="form-row">
<label for="node-input-pin"><i class="icon-asterisk"></i> Pin</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="7">7</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="18">18</option>
<option value="22">22</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('rpi-gpio out',{
category: 'deprecated',
color:"#c6dbef",
defaults: {
name: { value:""},
resistor: { value: "no"},
pin: {value:"",required:true},
},
inputs:1,
outputs:0,
icon: "rpi.png",
align: "right",
label: function() {
return this.name||"Pin: "+this.pin;
//+(this.resistor == "no"?"":" ("+(this.resistor=="pullup"?"":"&darr;")+")");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -1,48 +0,0 @@
/**
* 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(process.env.NODE_RED_HOME+"/red/red");
var gpio = require("pi-gpio");
function GPIOOutNode(n) {
RED.nodes.createNode(this,n);
this.warn("node type deprecated - will be removed in a future release");
this.pin = n.pin;
var node = this;
if (this.pin) {
gpio.open(this.pin,"output",function(err) {
if (err) {
node.error(err);
} else {
node.on("input",function(msg) {
gpio.write(node.pin,msg.payload,function(err) {
if (err) node.error(err);
});
});
}
});
} else {
this.error("Invalid GPIO pin: "+this.pin);
}
}
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
GPIOOutNode.prototype.close = function() {
gpio.close(this.pin);
}