From 3a4f87025752d1fc74a4b0cf32ffc0991f8334eb Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sun, 27 Apr 2014 16:39:09 +0100 Subject: [PATCH 01/20] make Prowl consistent with Pushbullet --- social/prowl/57-prowl.html | 3 +++ social/prowl/57-prowl.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/social/prowl/57-prowl.html b/social/prowl/57-prowl.html index 50796ffa..8c9229ff 100644 --- a/social/prowl/57-prowl.html +++ b/social/prowl/57-prowl.html @@ -32,6 +32,7 @@ +
Note: Using credentials from global pushkey.js file.
+ + + + + + diff --git a/social/pusher/114-pusher_send.js b/social/pusher/114-pusher_send.js new file mode 100644 index 00000000..ab2c5fd5 --- /dev/null +++ b/social/pusher/114-pusher_send.js @@ -0,0 +1,80 @@ +/** + * pusher_send.js + * Subscription module for the Pusher service (www.pusher.com) + * Requires 'pusher' module + * Copyright 2014 Charalampos Doukas - @BuildingIoT + * + * 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 Pusher = require('pusher'); + +// Require main module +var RED = require(process.env.NODE_RED_HOME+"/red/red"); + + +// The main node definition - most things happen in here +function PusherNodeSend(n) { + // Create a RED node + RED.nodes.createNode(this,n); + + var node = this; + + //get parameters from user + this.appid = n.appid; + this.appkey = n.appkey; + this.appsecret = n.appsecret; + this.channel = n.channel; + this.eventname = n.eventname; + + + var pusher = new Pusher({ + appId: this.appid, + key: this.appkey, + secret: this.appsecret + }); + + + this.on("input", function(msg){ + + pusher.trigger(this.channel, this.eventname, { + "message": ""+msg.payload + }); + + }); + + + this.on("close", function() { + // Called when the node is shutdown - eg on redeploy. + // Allows ports to be closed, connections dropped etc. + // eg: this.client.disconnect(); + }); + + } + + //hue debugging on the output: + var displayResult = function(result) { + console.log(result); +}; + +var displayError = function(err) { + console.error(err); +}; + + + + +// Register the node by name. This must be called before overriding any of the +// Node functions. +RED.nodes.registerType("Pusher out",PusherNodeSend); diff --git a/social/pusher/114-pusher_sub.html b/social/pusher/114-pusher_sub.html new file mode 100644 index 00000000..270eb20b --- /dev/null +++ b/social/pusher/114-pusher_sub.html @@ -0,0 +1,68 @@ + + + + + + + + + diff --git a/social/pusher/114-pusher_sub.js b/social/pusher/114-pusher_sub.js new file mode 100644 index 00000000..96012ae5 --- /dev/null +++ b/social/pusher/114-pusher_sub.js @@ -0,0 +1,80 @@ +/** + * pusher_sub.js + * Subscription module for the Pusher service (www.pusher.com) + * Requires 'pusher-client' module + * Copyright 2014 Charalampos Doukas - @BuildingIoT + * + * 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 Pusher = require('pusher-client'); + +// Require main module +var RED = require(process.env.NODE_RED_HOME+"/red/red"); + + +// The main node definition - most things happen in here +function PusherNode(n) { + // Create a RED node + RED.nodes.createNode(this,n); + + var node = this; + + //get parameters from user + this.apikey = n.apikey; + this.channel = n.channel; + this.eventname = n.eventname; + + + + //create a subscription to the channel and event defined by user + var socket = new Pusher(''+this.apikey); + var my_channel = socket.subscribe(''+this.channel); + socket.bind(''+this.eventname, + function(data) { + + var msg = {}; + msg.payload = data; + node.send(msg); + } + ); + + this.on("input", function(msg){ + + }); + + + this.on("close", function() { + // Called when the node is shutdown - eg on redeploy. + // Allows ports to be closed, connections dropped etc. + // eg: this.client.disconnect(); + }); + + } + + //hue debugging on the output: + var displayResult = function(result) { + console.log(result); +}; + +var displayError = function(err) { + console.error(err); +}; + + + + +// Register the node by name. This must be called before overriding any of the +// Node functions. +RED.nodes.registerType("Pusher",PusherNode); diff --git a/social/pusher/icons/pusher.png b/social/pusher/icons/pusher.png new file mode 100644 index 0000000000000000000000000000000000000000..04bc1635e9625bce080af99091303b31ca353e51 GIT binary patch literal 4216 zcmZuz1z1#F*BxMx4(U=yB&23&1sQ6nL1HK!kQ#bu0ZHkSk`_Vf5)cGwMur9vq*GcL zIt2mAAKv%p^_u>fDh5 zA^-qL<xp0gE>YXy}m&Jy0tG z9)Q3P3*mBCAXK8e$@9cQw;4}4oZVcJjx0FHY@Fm5HKMacOF<2&8}K%4~uTiuX&0ixMRy6ue?LmJwi_9J{IYCK9LUh{&L6;SzD0e|GI z5t^F%L8Y_ua2p(8ftliOLU6f`UHZqfKY(%E0FWw;73r9_BYxonh?CkSzPM0E{gJTA0C*NyFGT_) z;ARCk$KRrHt6!~7_9}J$m@>J_Ts3LzY$Qba+>5U>Dr@lj~P5f3V+t!x; z*s{%^rpdY6emdvSuimG6dt96S8FJAX`g8W1A0dqlfI|+0ceg6B$$Ee)ha0lEg^!v$ zAiys|K-KK~{o7&o#tH2|$+^j*HaG2E@iOhee5(&mGlQJIHHAqWrS@!}K6zBYC=+-O zPA_7qh$|>8c&yOdOHP^6Z*hJ^eYw~yf&Sjz#{WLEnQQbU zkcRk=F8DKva}zQ9rQ6Zjyf6XyhDspn;6z`Ypa9rC0uDzRZ+zd4XVgNZU$I|oO5;Dd z#tM61teo5-GmLaxP?KZVSw19>wQ%9g;b+dB3$bs(r->tS%OVvG1PkKxn^Ld^h&U6> zf&d`_D%1pT2*4`%Xj$NAIq8Y3M^I=2&pp`I888y)Jpj}Q5_i5~2z=U1;Y>yzpe#!o z*78^oZ#EE39JEVKpCeZs$B;*rDnCZeYC!A-lS4eDBj|ud#8D^6{u$uGu*gUnMTE`$w zS=-9Ez`6_I4>f5`B$oY3OfaZ~Bxc=HkdH%h;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Bx5JiO zIzvosWUrbGgYgr6w2=2UOi9wyLNYbzkT1XBW!=3t75@V%n!#XiiuaxUpJOWATH&db zywP9>mu2R*r0j2gx00L-ZdeStvZ&GF{LFH@ zd77MirtzabAwmNYF9eV=o9W|yEzakZ*cSCV{1Vi|)ss4!T5XQ(qhE$^$t(|S?(|kx zWCqN{yO(Q6mu3}>iPi>OG=nda{O4&j~Z8_Si>|Ff~Ktt z8%o)A_4<4aHycoH_d6!8u#l$kR-a|X9En#ARA6xjL;j2mt?=WN>73^^^|Heg&s#w~ z3sCzoid}-7Zs8!J1*I;_#e-g1oq3v70aHocK)#cogDF*I@7AY(cySSIByJERCnvpf zyO<-Qp9B@un2#ggOBskI4iLZcxu|Z~^9Mzcp5d)`ga*!>(XC&9&f$t03T5)9LH`Au CmDLmg literal 0 HcmV?d00001 From 191f4412f68a7a1a62ce6504afc15b32ea4f7750 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 17 May 2014 18:30:21 +0100 Subject: [PATCH 04/20] can't spell yellow ... --- hardware/Pi/78-ledborg.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/Pi/78-ledborg.html b/hardware/Pi/78-ledborg.html index 55d128fe..86ce75e4 100644 --- a/hardware/Pi/78-ledborg.html +++ b/hardware/Pi/78-ledborg.html @@ -27,7 +27,7 @@

See the PiBorg site for more information.

You can also now use a msg.payload in the standard hex format "#rrggbb". The clip levels are :

0x00 - 0x57 = off
0x58 - 0xA7 = 50%
0xA8 - 0xFF = fully on

-

You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yeloow, orange, pink, purple, +

You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple, white, warmwhite, black

From 9adc2b2687db66b42eab01efb18dd50720137ab9 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 17 May 2014 18:32:13 +0100 Subject: [PATCH 05/20] add some status to suncalc (to see how it looks) --- time/79-suncalc.js | 75 ++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/time/79-suncalc.js b/time/79-suncalc.js index 2b265391..942d4aa2 100644 --- a/time/79-suncalc.js +++ b/time/79-suncalc.js @@ -14,44 +14,47 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var SunCalc = require('suncalc'); +module.exports = function(RED) { + var SunCalc = require('suncalc'); -function SunNode(n) { - RED.nodes.createNode(this,n); - this.lat = n.lat; - this.lon = n.lon; - this.start = n.start; - this.end = n.end; + function SunNode(n) { + RED.nodes.createNode(this,n); + this.lat = n.lat; + this.lon = n.lon; + this.start = n.start; + this.end = n.end; - var node = this; - var oldval = null; + var node = this; + var oldval = null; - this.tick = setInterval(function() { - var now = new Date(); - var hour = now.getUTCHours(); - var mins = now.getUTCMinutes(); - var times = SunCalc.getTimes(now, node.lat, node.lon); - var hour1 = times[node.start].getUTCHours(); - var mins1 = times[node.start].getUTCMinutes(); - var hour2 = times[node.end].getUTCHours(); - var mins2 = times[node.end].getUTCMinutes(); - var e1 = (hour*60+mins) - (hour1*60+mins1); - var e2 = (hour*60+mins) - (hour2*60+mins2); - var moon = SunCalc.getMoonIllumination(now).fraction; - msg = { payload:0, topic:"sun", moon:moon }; - if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; } - if (oldval == null) { oldval = msg.payload; } - if (msg.payload != oldval) { - oldval = msg.payload; - msg2 = msg; - node.send( [msg,msg2] ); - } - else { node.send(msg); } - }, 60000); + this.tick = setInterval(function() { + var now = new Date(); + var hour = now.getUTCHours(); + var mins = now.getUTCMinutes(); + var times = SunCalc.getTimes(now, node.lat, node.lon); + var hour1 = times[node.start].getUTCHours(); + var mins1 = times[node.start].getUTCMinutes(); + var hour2 = times[node.end].getUTCHours(); + var mins2 = times[node.end].getUTCMinutes(); + var e1 = (hour*60+mins) - (hour1*60+mins1); + var e2 = (hour*60+mins) - (hour2*60+mins2); + var moon = SunCalc.getMoonIllumination(now).fraction; + msg = { payload:0, topic:"sun", moon:moon }; + if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; } + if (oldval == null) { oldval = msg.payload; } + if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"},true); } + else { node.status({fill:"blue",shape:"dot",text:"night"},true); } + if (msg.payload != oldval) { + oldval = msg.payload; + msg2 = msg; + node.send( [msg,msg2] ); + } + else { node.send(msg); } + }, 60000); - this.on("close", function() { - clearInterval(this.tick); - }); + this.on("close", function() { + clearInterval(this.tick); + }); + } + RED.nodes.registerType("sunrise",SunNode); } -RED.nodes.registerType("sunrise",SunNode); From f9ff63c346db65297f80e867a4a61e9848478f74 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 17 May 2014 21:06:58 +0100 Subject: [PATCH 06/20] updates to mpd node --- social/music/69-mpd.html | 4 ++-- social/music/69-mpd.js | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/social/music/69-mpd.html b/social/music/69-mpd.html index acfc07be..b06bd5e7 100644 --- a/social/music/69-mpd.html +++ b/social/music/69-mpd.html @@ -24,7 +24,7 @@ + + + + + + + + + + + + + + diff --git a/social/pusher/114-pusher.js b/social/pusher/114-pusher.js new file mode 100644 index 00000000..90ecf0c7 --- /dev/null +++ b/social/pusher/114-pusher.js @@ -0,0 +1,187 @@ +/** + * pusher_send.js + * Subscription module for the Pusher service (www.pusher.com) + * Requires 'pusher' module + * Copyright 2014 Charalampos Doukas - @BuildingIoT + * + * 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 Pusher = require('pusher'); +var PusherClient = require('pusher-client'); + +// Require main module +var RED = require(process.env.NODE_RED_HOME+"/red/red"); + + +// The main node definition - most things happen in here +//Node for sending Pusher events +function PusherNodeSend(n) { + // Create a RED node + RED.nodes.createNode(this,n); + + var node = this; + + var credentials = RED.nodes.getCredentials(n.id); + + if ((credentials) && (credentials.hasOwnProperty("pusherappid"))) { this.appid = credentials.pusherappid; } + else { this.error("No Pusher api token set"); } + if ((credentials) && (credentials.hasOwnProperty("pusherappsecret"))) { this.appsecret = credentials.pusherappsecret; } + else { this.error("No Pusher user secret set"); } + + if ((credentials) && (credentials.hasOwnProperty("pusherappkey"))) { this.appkey = credentials.pusherappkey; } + else { this.error("No Pusher user key set"); } + + //get parameters from user + this.channel = n.channel; + this.eventname = n.eventname; + + var pusher = new Pusher({ + appId: this.appid, + key: this.appkey, + secret: this.appsecret + }); + + + this.on("input", function(msg){ + + pusher.trigger(this.channel, this.eventname, { + "message": ""+msg.payload + }); + + }); + + + this.on("close", function() { + // Called when the node is shutdown - eg on redeploy. + // Allows ports to be closed, connections dropped etc. + // eg: this.client.disconnect(); + }); + + } + +//node for subscribing to an event/channel + function PusherNode(n) { + // Create a RED node + RED.nodes.createNode(this,n); + + var node = this; + var credentials = RED.nodes.getCredentials(n.id); + + if ((credentials) && (credentials.hasOwnProperty("pusherappkey_sub"))) { this.appkey = credentials.pusherappkey_sub; } + else { this.error("No Pusher app key set for input node"); } + + //get parameters from user + this.channel = n.channel; + this.eventname = n.eventname; + + + + //create a subscription to the channel and event defined by user + var socket = new PusherClient(''+this.appkey); + var my_channel = socket.subscribe(''+this.channel); + socket.bind(''+this.eventname, + function(data) { + + var msg = {}; + msg.payload = data; + node.send(msg); + } + ); + + this.on("input", function(msg){ + + }); + + + this.on("close", function() { + // Called when the node is shutdown - eg on redeploy. + // Allows ports to be closed, connections dropped etc. + // eg: this.client.disconnect(); + socket.disconnect(); + }); + + } + + //debugging on the output: + var displayResult = function(result) { + console.log(result); +}; + +var displayError = function(err) { + console.error(err); +}; + + + + +// Register the node by name. This must be called before overriding any of the +// Node functions. +RED.nodes.registerType("Pusher out",PusherNodeSend); +RED.nodes.registerType("Pusher",PusherNode); + +var querystring = require('querystring'); + +RED.httpAdmin.get('/pusher/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({pusherappid:credentials.pusherappid,pusherappsecret:credentials.pusherappsecret, pusherappkey:credentials.pusherappkey, pusherappkey_sub:credentials.pusherappkey_sub})); + } else { + res.send(JSON.stringify({})); + } +}); + +RED.httpAdmin.delete('/pusher/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); + res.send(200); +}); + +RED.httpAdmin.post('/pusher/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + + if (newCreds.pusherappid == null || newCreds.pusherappid == "") { + delete credentials.pusherappid; + } else { + credentials.pusherappid = newCreds.pusherappid; + } + if (newCreds.pusherappkey == "") { + delete credentials.pusherappkey; + } else { + credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey; + } + + if (newCreds.pusherappsecret == "") { + delete credentials.pusherappsecret; + } else { + credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret; + } + + if (newCreds.pusherappkey_sub == "") { + delete credentials.pusherappkey_sub; + } else { + credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub; + } + + + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); +}); + diff --git a/social/pusher/114-pusher_send.html b/social/pusher/114-pusher_send.html deleted file mode 100644 index cb3d00d0..00000000 --- a/social/pusher/114-pusher_send.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - diff --git a/social/pusher/114-pusher_send.js b/social/pusher/114-pusher_send.js deleted file mode 100644 index ab2c5fd5..00000000 --- a/social/pusher/114-pusher_send.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * pusher_send.js - * Subscription module for the Pusher service (www.pusher.com) - * Requires 'pusher' module - * Copyright 2014 Charalampos Doukas - @BuildingIoT - * - * 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 Pusher = require('pusher'); - -// Require main module -var RED = require(process.env.NODE_RED_HOME+"/red/red"); - - -// The main node definition - most things happen in here -function PusherNodeSend(n) { - // Create a RED node - RED.nodes.createNode(this,n); - - var node = this; - - //get parameters from user - this.appid = n.appid; - this.appkey = n.appkey; - this.appsecret = n.appsecret; - this.channel = n.channel; - this.eventname = n.eventname; - - - var pusher = new Pusher({ - appId: this.appid, - key: this.appkey, - secret: this.appsecret - }); - - - this.on("input", function(msg){ - - pusher.trigger(this.channel, this.eventname, { - "message": ""+msg.payload - }); - - }); - - - this.on("close", function() { - // Called when the node is shutdown - eg on redeploy. - // Allows ports to be closed, connections dropped etc. - // eg: this.client.disconnect(); - }); - - } - - //hue debugging on the output: - var displayResult = function(result) { - console.log(result); -}; - -var displayError = function(err) { - console.error(err); -}; - - - - -// Register the node by name. This must be called before overriding any of the -// Node functions. -RED.nodes.registerType("Pusher out",PusherNodeSend); diff --git a/social/pusher/114-pusher_sub.html b/social/pusher/114-pusher_sub.html deleted file mode 100644 index 270eb20b..00000000 --- a/social/pusher/114-pusher_sub.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - diff --git a/social/pusher/114-pusher_sub.js b/social/pusher/114-pusher_sub.js deleted file mode 100644 index 96012ae5..00000000 --- a/social/pusher/114-pusher_sub.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * pusher_sub.js - * Subscription module for the Pusher service (www.pusher.com) - * Requires 'pusher-client' module - * Copyright 2014 Charalampos Doukas - @BuildingIoT - * - * 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 Pusher = require('pusher-client'); - -// Require main module -var RED = require(process.env.NODE_RED_HOME+"/red/red"); - - -// The main node definition - most things happen in here -function PusherNode(n) { - // Create a RED node - RED.nodes.createNode(this,n); - - var node = this; - - //get parameters from user - this.apikey = n.apikey; - this.channel = n.channel; - this.eventname = n.eventname; - - - - //create a subscription to the channel and event defined by user - var socket = new Pusher(''+this.apikey); - var my_channel = socket.subscribe(''+this.channel); - socket.bind(''+this.eventname, - function(data) { - - var msg = {}; - msg.payload = data; - node.send(msg); - } - ); - - this.on("input", function(msg){ - - }); - - - this.on("close", function() { - // Called when the node is shutdown - eg on redeploy. - // Allows ports to be closed, connections dropped etc. - // eg: this.client.disconnect(); - }); - - } - - //hue debugging on the output: - var displayResult = function(result) { - console.log(result); -}; - -var displayError = function(err) { - console.error(err); -}; - - - - -// Register the node by name. This must be called before overriding any of the -// Node functions. -RED.nodes.registerType("Pusher",PusherNode); From f831f0f502db78cbd26305a33104f36a4cda609e Mon Sep 17 00:00:00 2001 From: hdoukas Date: Mon, 19 May 2014 11:08:15 +0200 Subject: [PATCH 08/20] lower case node name and pusher in fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed lower case node name and replace input node to ‘pusher in’ --- social/pusher/114-pusher.html | 16 ++++++++-------- social/pusher/114-pusher.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/social/pusher/114-pusher.html b/social/pusher/114-pusher.html index a4596f87..ea91ebb6 100644 --- a/social/pusher/114-pusher.html +++ b/social/pusher/114-pusher.html @@ -16,7 +16,7 @@ --> - - - - + + + + + + + + + + + + + + diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js new file mode 100644 index 00000000..61a14bee --- /dev/null +++ b/io/stomp/18-stomp.js @@ -0,0 +1,146 @@ +/** + * Copyright 2014 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. + **/ + +module.exports = function(RED) { + "use strict"; + var StompClient = require('stomp-client'); + var querystring = require('querystring'); + + function StompServerNode(n) { + RED.nodes.createNode(this,n); + this.server = n.server; + this.port = n.port; + this.name = n.name; + var credentials = RED.nodes.getCredentials(n.id); + if (credentials) { + this.username = credentials.user; + this.password = credentials.password; + } + } + RED.nodes.registerType("stomp-server",StompServerNode); + + RED.httpAdmin.get('/stomp-server/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")})); + } else { + res.send(JSON.stringify({})); + } + }); + + RED.httpAdmin.delete('/stomp-server/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); + res.send(200); + }); + + RED.httpAdmin.post('/stomp-server/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.user == null || newCreds.user == "") { + delete credentials.user; + } else { + credentials.user = newCreds.user; + } + if (newCreds.password == "") { + delete credentials.password; + } else { + credentials.password = newCreds.password||credentials.password; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); + + + function StompInNode(n) { + RED.nodes.createNode(this,n); + this.server = n.server; + this.topic = n.topic; + + this.serverConfig = RED.nodes.getNode(this.server); + this.host = this.serverConfig.server; + this.port = this.serverConfig.port; + this.userid = this.serverConfig.username; + this.password = this.serverConfig.password; + + var node = this; + var msg = {topic:this.topic}; + + node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0'); + + node.client.connect(function(sessionId) { + node.log('subscribed to: '+node.topic); + node.client.subscribe(node.topic, function(body, headers) { + msg.payload = JSON.parse(body); + node.send(msg); + }); + }, function(error) { node.warn(error); }); + + node.client.on("error", function(error) { + node.log(error); + }); + + node.on("close", function(done) { + if (node.client) { + node.client.on("disconnect", function() { + done(); + }); + //node.client.unsubscribe(node.topic); + node.client.disconnect(); + } else { done(); } + }); + } + RED.nodes.registerType("stomp in",StompInNode); + + + function StompOutNode(n) { + RED.nodes.createNode(this,n); + this.server = n.server; + this.topic = n.topic; + + this.serverConfig = RED.nodes.getNode(this.server); + this.host = this.serverConfig.server; + this.port = this.serverConfig.port; + this.userid = this.serverConfig.username; + this.password = this.serverConfig.password; + + var node = this; + var msg = {topic:this.topic}; + + node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0'); + + node.client.connect(); + + node.client.on("error", function(error) { + node.log(error); + }); + + node.on("input", function(msg) { + node.client.publish(node.topic || msg.topic, msg.payload); + }); + + node.on("close", function(done) { + if (client) { client.disconnect(); } + }); + } + RED.nodes.registerType("stomp out",StompOutNode); + +} From 81f59a853d182d55794ae5824a3f070986d2f2da Mon Sep 17 00:00:00 2001 From: hdoukas Date: Sat, 24 May 2014 14:31:02 +0200 Subject: [PATCH 10/20] fixed credentials to never show up in the flow removed credentials from the defaults section in pusher.html, added oneditprepare to read them back from credentials.json when edited --- social/pusher/114-pusher.html | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/social/pusher/114-pusher.html b/social/pusher/114-pusher.html index ea91ebb6..7f07fe57 100644 --- a/social/pusher/114-pusher.html +++ b/social/pusher/114-pusher.html @@ -51,7 +51,6 @@ color:"#A9D0F5", defaults: { // defines the editable properties of the node name: {value:""}, // along with default values. - appkey_sub: {value:"", required:true}, channel: {value:"", required:true}, eventname: {value:"", required:true} }, @@ -77,6 +76,13 @@ success: function(result){} }); }, + oneditprepare: function() { + $.getJSON('pusher/'+this.id,function(data) { + if (data.pusherappkey_sub) { + $('#node-input-appkey_sub').val(data.pusherappkey_sub); + } + }); + }, ondelete: function() { $.ajax({ url: 'pusher/'+this.id, @@ -132,11 +138,9 @@ color:"#A9D0F5", defaults: { // defines the editable properties of the node name: {value:""}, // along with default values. - appid: {value:"", required:true}, - appkey: {value:"", required:true}, - appsecret: {value:"", required:true}, channel: {value:"", required:true}, - eventname: {value:"", required:true} + eventname: {value:"", required:true}, + appid: {value:"", required:true} }, inputs:1, // set the number of inputs - only 0 or 1 outputs:0, // set the number of outputs - 0 to n @@ -165,6 +169,21 @@ success: function(result){} }); }, + oneditprepare: function() { + $.getJSON('pusher/'+this.id,function(data) { + if (data.pusherappid) { + $('#node-input-appid').val(data.pusherappid); + } + if (data.pusherappkey) { + $('#node-input-appkey').val(data.pusherappkey); + } + + if (data.pusherappsecret) { + $('#node-input-appsecret').val(data.pusherappsecret); + } + + }); + }, ondelete: function() { $.ajax({ url: 'pusher/'+this.id, From fe0222d49871ea948c093228104690b276054c5b Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 24 May 2014 16:38:35 +0100 Subject: [PATCH 11/20] Quick tidy up of pusher node - remove final key from flow, fix in/out order on palette. --- social/pusher/114-pusher.html | 66 +++++++-------- social/pusher/114-pusher.js | 146 ++++++++++++++-------------------- 2 files changed, 85 insertions(+), 127 deletions(-) diff --git a/social/pusher/114-pusher.html b/social/pusher/114-pusher.html index 7f07fe57..c5536074 100644 --- a/social/pusher/114-pusher.html +++ b/social/pusher/114-pusher.html @@ -1,4 +1,5 @@ - + - + - + - + + + + + + + - + + + + diff --git a/social/xmpp/92-xmpp.js b/social/xmpp/92-xmpp.js index f7755bc3..bc2aa4d0 100644 --- a/social/xmpp/92-xmpp.js +++ b/social/xmpp/92-xmpp.js @@ -1,5 +1,5 @@ /** - * Copyright 2013 IBM Corp. + * Copyright 2013,2014 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,48 +14,92 @@ * limitations under the License. **/ -var orig=console.warn; -console.warn=(function() { // suppress warning from stringprep when not needed) - var orig=console.warn; - return function() { - //orig.apply(console, arguments); - }; -})(); +module.exports = function(RED) { +"use strict"; +var XMPP = require('simple-xmpp'); -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var xmpp = require('simple-xmpp'); -console.warn = orig; +try { var xmppkey = RED.settings.xmpp || require(process.env.NODE_RED_HOME+"/../xmppkeys.js"); } +catch(err) { } -try { - var xmppkey = RED.settings.xmpp || require(process.env.NODE_RED_HOME+"/../xmppkeys.js"); -} catch(err) { - throw new Error("Failed to load XMPP credentials"); -} - -function XmppNode(n) { +function XMPPServerNode(n) { RED.nodes.createNode(this,n); this.server = n.server; this.port = n.port; + this.nickname = n.nickname; + var credentials = RED.nodes.getCredentials(n.id); + if (credentials) { + this.username = credentials.user; + this.password = credentials.password; + } +} +RED.nodes.registerType("xmpp-server",XMPPServerNode); + +var querystring = require('querystring'); + +RED.httpAdmin.get('/xmpp-server/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")})); + } else if (xmppkey && xmppkey.jid && xmppkey.password) { + RED.nodes.addCredentials(req.params.id,{user:xmppkey.jid, password:xmppkey.password, global:true}); + credentials = RED.nodes.getCredentials(req.params.id); + res.send(JSON.stringify({user:credentials.user,global:credentials.global,hasPassword:(credentials.password&&credentials.password!="")})); + } else { + res.send(JSON.stringify({})); + } +}); + +RED.httpAdmin.delete('/xmpp-server/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); + res.send(200); +}); + +RED.httpAdmin.post('/xmpp-server/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.user == null || newCreds.user == "") { + delete credentials.user; + } else { + credentials.user = newCreds.user; + } + if (newCreds.password == "") { + delete credentials.password; + } else { + credentials.password = newCreds.password||credentials.password; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); +}); + + +function XmppInNode(n) { + RED.nodes.createNode(this,n); + this.server = n.server; + + this.serverConfig = RED.nodes.getNode(this.server); + this.host = this.serverConfig.server; + this.port = this.serverConfig.port; + this.nick = this.serverConfig.nickname || "Node-RED"; + this.userid = this.serverConfig.username; + this.password = this.serverConfig.password; + this.join = n.join || false; - this.nick = n.nick || "Node-RED"; this.sendAll = n.sendObject; this.to = n.to || ""; var node = this; - setTimeout(function() { - xmpp.connect({ - jid : xmppkey.jid, - password : xmppkey.password, - host : this.server, - port : this.port, - skipPresence : true, - reconnect : false - }); - }, 5000); + var xmpp = new XMPP.SimpleXMPP(); xmpp.on('online', function() { - node.log('connected to '+node.server); - xmpp.setPresence('online', node.nick+' online'); + node.log('connected to '+node.host+":"+node.port); + node.status({fill:"green",shape:"dot",text:"connected"},true); + //xmpp.setPresence('online', node.nick+' online'); if (node.join) { xmpp.join(node.to+'/'+node.nick); } @@ -84,39 +128,126 @@ function XmppNode(n) { }); xmpp.on('error', function(err) { - console.error(err); + console.error("error",err); }); xmpp.on('close', function(err) { node.log('connection closed'); + node.status({fill:"red",shape:"ring",text:"not connected"},true); }); xmpp.on('subscribe', function(from) { xmpp.acceptSubscription(from); }); - this.on("input", function(msg) { - var to = msg.topic; - if (node.to != "") { to = node.to; } - if (node.sendAll) { - xmpp.send(to, JSON.stringify(msg), node.join); - } - else { - xmpp.send(to, msg.payload, node.join); - } - }); + // Now actually make the connection + try { + xmpp.connect({ + jid : node.userid, + password : node.password, + host : node.host, + port : node.port, + skipPresence : true, + reconnect : false + }); + } catch(e) { + node.error("Bad xmpp configuration"); + node.status({fill:"red",shape:"ring",text:"not connected"},true); + } - this.on("close", function() { - xmpp.setPresence('offline'); - try { - xmpp.disconnect(); - // TODO - DCJ NOTE... this is not good. It leaves the connection up over a restart - which will end up with bad things happening... - // (but requires the underlying xmpp lib to be fixed, which does have an open bug request on fixing the close method - and a work around. - // see - https://github.com/simple-xmpp/node-simple-xmpp/issues/12 for the fix - } catch(e) { - this.warn("Due to an underlying bug in the xmpp library this does not disconnect old sessions. This is bad... A restart would be better."); - } + node.on("close", function(done) { + //xmpp.setPresence('offline'); + if (xmpp.conn) { xmpp.conn.end(); } + xmpp = null; + done(); }); } +RED.nodes.registerType("xmpp in",XmppInNode); -RED.nodes.registerType("xmpp",XmppNode); +function XmppOutNode(n) { + RED.nodes.createNode(this,n); + this.server = n.server; + + this.serverConfig = RED.nodes.getNode(this.server); + this.host = this.serverConfig.server; + this.port = this.serverConfig.port; + this.nick = this.serverConfig.nickname || "Node-RED"; + this.userid = this.serverConfig.username; + this.password = this.serverConfig.password; + + this.join = n.join || false; + this.sendAll = n.sendObject; + this.to = n.to || ""; + var node = this; + + var xmpp = new XMPP.SimpleXMPP(); + + xmpp.on('online', function() { + node.log('connected to '+node.host+":"+node.port); + node.status({fill:"green",shape:"dot",text:"connected"},true); + xmpp.setPresence('online', node.nick+' online'); + if (node.join) { + xmpp.join(node.to+'/'+node.nick); + } + }); + + xmpp.on('error', function(err) { + console.error("error",err); + }); + + xmpp.on('close', function(err) { + node.log('connection closed'); + node.status({fill:"red",shape:"ring",text:"not connected"},true); + }); + + xmpp.on('subscribe', function(from) { + xmpp.acceptSubscription(from); + }); + + // Now actually make the connection + try { + xmpp.connect({ + jid : node.userid, + password : node.password, + host : node.host, + port : node.port, + skipPresence : true, + reconnect : false + }); + } catch(e) { + node.error("Bad xmpp configuration"); + node.status({fill:"red",shape:"ring",text:"not connected"},true); + } + + node.on("input", function(msg) { + if (msg.presence) { + if (['away', 'dnd', 'xa','chat'].indexOf(msg.presence) > -1 ) { + xmpp.setPresence(msg.presence, msg.payload); + } + else { node.warn("Can't set presence - invalid value"); } + } + else { + var to = msg.topic; + if (node.to != "") { to = node.to; } + if (node.sendAll) { + xmpp.send(to, JSON.stringify(msg), node.join); + } + else if (msg.payload) { + if (typeof(msg.payload) === "object") { + xmpp.send(to, JSON.stringify(msg.payload), node.join); + } else { + xmpp.send(to, msg.payload.toString(), node.join); + } + } + } + }); + + node.on("close", function() { + xmpp.setPresence('offline'); + if (xmpp.conn) { xmpp.conn.end(); } + xmpp = null; + }); +} +RED.nodes.registerType("xmpp out",XmppOutNode); + +} From f2dd4ae062039991312de9a67829f1252b8c7aa6 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Thu, 29 May 2014 18:32:20 +0100 Subject: [PATCH 15/20] tidy up logging on Stomp node --- io/stomp/18-stomp.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js index 0120cfed..f2c56eec 100644 --- a/io/stomp/18-stomp.js +++ b/io/stomp/18-stomp.js @@ -104,7 +104,6 @@ module.exports = function(RED) { node.client.on("disconnect", function() { node.status({fill:"red",shape:"ring",text:"disconnected"},true); - node.log("disconnected at "+Date().toString()); if (!closing) { setTimeout( function () { doConnect(); }, 15000); } @@ -112,7 +111,7 @@ module.exports = function(RED) { node.client.on("error", function(error) { node.status({fill:"grey",shape:"dot",text:"error"},true); - node.log("error: "+error); + node.log(error); }); doConnect(); @@ -158,7 +157,6 @@ module.exports = function(RED) { node.client.on("disconnect", function() { node.status({fill:"red",shape:"ring",text:"disconnected"},true); - node.log("disconnected at "+Date().toString()); if (!closing) { setTimeout( function () { node.client.connect(); }, 15000); } From be810be2e244a6d611063501b86e7077a2bc5924 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 31 May 2014 20:08:15 +0100 Subject: [PATCH 16/20] tweak node.status to be consistent with latest thinking stomp, xmpp and suncalc. --- io/stomp/18-stomp.js | 18 +++++++++--------- social/xmpp/92-xmpp.js | 12 ++++++------ time/79-suncalc.js | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js index f2c56eec..adbadb8e 100644 --- a/io/stomp/18-stomp.js +++ b/io/stomp/18-stomp.js @@ -86,31 +86,31 @@ module.exports = function(RED) { var closing = false; node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0'); - node.status({fill:"grey",shape:"ring",text:"connecting"},true); + node.status({fill:"grey",shape:"ring",text:"connecting"}); var doConnect = function() { node.client.connect(function(sessionId) { - node.status({fill:"green",shape:"dot",text:"connected"},true); + node.status({fill:"green",shape:"dot",text:"connected"}); node.log('subscribed to: '+node.topic); node.client.subscribe(node.topic, function(body, headers) { msg.payload = JSON.parse(body); node.send(msg); }); }, function(error) { - node.status({fill:"grey",shape:"dot",text:"error"},true); + node.status({fill:"grey",shape:"dot",text:"error"}); node.warn(error); }); } node.client.on("disconnect", function() { - node.status({fill:"red",shape:"ring",text:"disconnected"},true); + node.status({fill:"red",shape:"ring",text:"disconnected"}); if (!closing) { setTimeout( function () { doConnect(); }, 15000); } }); node.client.on("error", function(error) { - node.status({fill:"grey",shape:"dot",text:"error"},true); + node.status({fill:"grey",shape:"dot",text:"error"}); node.log(error); }); @@ -146,17 +146,17 @@ module.exports = function(RED) { var closing = false; node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0'); - node.status({fill:"grey",shape:"ring",text:"connecting"},true); + node.status({fill:"grey",shape:"ring",text:"connecting"}); node.client.connect( function(sessionId) { - node.status({fill:"green",shape:"dot",text:"connected"},true); + node.status({fill:"green",shape:"dot",text:"connected"}); }, function(error) { - node.status({fill:"grey",shape:"dot",text:"error"},true); + node.status({fill:"grey",shape:"dot",text:"error"}); node.warn(error); }); node.client.on("disconnect", function() { - node.status({fill:"red",shape:"ring",text:"disconnected"},true); + node.status({fill:"red",shape:"ring",text:"disconnected"}); if (!closing) { setTimeout( function () { node.client.connect(); }, 15000); } diff --git a/social/xmpp/92-xmpp.js b/social/xmpp/92-xmpp.js index bc2aa4d0..8bcb2955 100644 --- a/social/xmpp/92-xmpp.js +++ b/social/xmpp/92-xmpp.js @@ -98,7 +98,7 @@ function XmppInNode(n) { xmpp.on('online', function() { node.log('connected to '+node.host+":"+node.port); - node.status({fill:"green",shape:"dot",text:"connected"},true); + node.status({fill:"green",shape:"dot",text:"connected"}); //xmpp.setPresence('online', node.nick+' online'); if (node.join) { xmpp.join(node.to+'/'+node.nick); @@ -133,7 +133,7 @@ function XmppInNode(n) { xmpp.on('close', function(err) { node.log('connection closed'); - node.status({fill:"red",shape:"ring",text:"not connected"},true); + node.status({fill:"red",shape:"ring",text:"not connected"}); }); xmpp.on('subscribe', function(from) { @@ -152,7 +152,7 @@ function XmppInNode(n) { }); } catch(e) { node.error("Bad xmpp configuration"); - node.status({fill:"red",shape:"ring",text:"not connected"},true); + node.status({fill:"red",shape:"ring",text:"not connected"}); } node.on("close", function(done) { @@ -184,7 +184,7 @@ function XmppOutNode(n) { xmpp.on('online', function() { node.log('connected to '+node.host+":"+node.port); - node.status({fill:"green",shape:"dot",text:"connected"},true); + node.status({fill:"green",shape:"dot",text:"connected"}); xmpp.setPresence('online', node.nick+' online'); if (node.join) { xmpp.join(node.to+'/'+node.nick); @@ -197,7 +197,7 @@ function XmppOutNode(n) { xmpp.on('close', function(err) { node.log('connection closed'); - node.status({fill:"red",shape:"ring",text:"not connected"},true); + node.status({fill:"red",shape:"ring",text:"not connected"}); }); xmpp.on('subscribe', function(from) { @@ -216,7 +216,7 @@ function XmppOutNode(n) { }); } catch(e) { node.error("Bad xmpp configuration"); - node.status({fill:"red",shape:"ring",text:"not connected"},true); + node.status({fill:"red",shape:"ring",text:"not connected"}); } node.on("input", function(msg) { diff --git a/time/79-suncalc.js b/time/79-suncalc.js index 942d4aa2..6e2d3096 100644 --- a/time/79-suncalc.js +++ b/time/79-suncalc.js @@ -42,8 +42,8 @@ module.exports = function(RED) { msg = { payload:0, topic:"sun", moon:moon }; if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; } if (oldval == null) { oldval = msg.payload; } - if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"},true); } - else { node.status({fill:"blue",shape:"dot",text:"night"},true); } + if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"}); } + else { node.status({fill:"blue",shape:"dot",text:"night"}); } if (msg.payload != oldval) { oldval = msg.payload; msg2 = msg; From 192c4231531fc2de3e9da0d37a37f5638fb3a55c Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 4 Jun 2014 22:29:09 +0100 Subject: [PATCH 17/20] Update some icons --- hardware/BBB/icons/BBB.png | Bin 719 -> 1305 bytes social/twilio/icons/twilio.png | Bin 553 -> 383 bytes storage/leveldb/icons/leveldb.png | Bin 0 -> 1676 bytes storage/postgres/icons/postgres.png | Bin 625 -> 582 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 storage/leveldb/icons/leveldb.png diff --git a/hardware/BBB/icons/BBB.png b/hardware/BBB/icons/BBB.png index 0f2287741bb9458d83a489a139bde0d549fa2fd8..18c2ca9f505b0f7228ce32c261e070ef1b17afd3 100644 GIT binary patch delta 1300 zcmV+v1?&3H1(^y!iBL{Q4GJ0x0000DNk~Le0000i0000i2nGNE03L)|0RR910drDE zLIAGL9O(c600v@9M??Ss00000`9r&Zkuev400(qQO+^RZ1_Tur1m)VLT>tk(xrcgLgsRhOM;!;|7OOUt=#$7s;ZW%mixTQl%sXH`u>ANjM zaXGj`mJS{?+;&rznBXfm@m8DA69vnQRS;LWMT=ij>MrlO&+laWNmj1Q{T35Ne)_zB z-~0al=x5-y-L7d_Ei`GCbpQnbdd$BmfS}kK)BhD%f-JQ2jVAkBw!n$p7JvzW={Dfn zmY^j8Qm>iAg@^Cne}Z3s`C{SWi)l3g;5(6f0^l+&w3ZTfubpok11JG7Yvxdw*SmZF z2>^)Db9$rGepneek^3Mm^iE3HA1uRvJFpC|Y#CneVp`SY%?qFl=jdGaq#ynO&U4rv)4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;c!3By)(O{Jeka%xtW<~&$%Bn zyGuV0wyOU@7x8HAgNqa&{~Wofj22???QVW!u(Nk^@#P)kfAe3jurJpai9;oU7<+Nw z-1aW7pBK89-DetD`|IDiF)cxqq_=v5bD|v)k`dGD4yr121Llo%nK2u)uBj{(AM>MLDz>)67K; zt;OY5(o}lJU@&k^4ei996*J03CeB>fdTh54i}m%34F&*u@>+QE}6s&oS zy$ms0spPt$N8g)I$1aKuC|c|3sm|D1xqzn+l|+k)f7VO7+8r;oOm>`y4L)vAmRP|9 z@$}S1ib%$=&U)rrL2e>3X}5AklLMS87-;=X5V5u@V+k4Y;}I82waK%W`!32M^9tD2 zwldc4e}$72hcj=nSQ&c-C%TvG5}>3STR^zFi8Hm?Jje7JyrD&EwE+k{|48$3;+NC07*qoM6N<$f*;&Vz5oCK diff --git a/social/twilio/icons/twilio.png b/social/twilio/icons/twilio.png index ada41a2c82da6070a988e017f6cf691349ccd0cb..f8f91a5958ee81d668205703423548bb677a0a8f 100644 GIT binary patch literal 383 zcmeAS@N?(olHy`uVBq!ia0vp^B0wz1!3HFCgzU0`6k~CayA#8@b22Z19JVBHcNZWH z1V5d3*8?fe0*}aI1_o|n5N2eUHAey{$X?><>&kwQjYX7OusmCL6;MdB#5JPCIX^cy zHLrxhxhOTUBsE2$JhLQ2!QIn0AiR-J9H{7)r;B5V$MLsQ4EdTIL|p8ToN}&U=kl;% zS-X7Umd|2S;+iH2M_jDnSu?Ly-bg6KsH{jA&{$qcLkjJp1JYGWCX z3N2(=@v~3L>g0 zxbj!Th6JuiSZesRpuZ@_+Wm2OTH40!XGuRcCG46qd-lw?dn`^IyLv{aYmsom-&?YK zuh@p0J_=aBXzFec@jHoHd&6YS7S+c*aNX&8bg=d#Wzp$Pzq_>qPH delta 534 zcmV+x0_pw#0;vRliBL{Q4GJ0x0000DNk~Le0000Z0000o2m=5B0O5_2RR9100drDE zLIAGL9O(c60FY2jR7L;&{r~^}{QUg>{{H>_{r%g)da`2FYT|NQ*?{r&yx z?EU8F|Nj2}{Qds=`|j@U{qFDd^z{Dp^!xk!|NHyX)7AcE?(WLV%>VlO)YaC!y}$kG z>i+Wc`T6=BPu2>%>@7e0R>4! zK~y-)?UdUJ!Y~X#+qCN36cI%fBZw#>`v2c&*K69P4&RrTHtAWKOEV!Ru_BX<0yRv^ zF-Y=KL6laCgQ5wX(X1upRn6U=tGWmgC{!&-I^ezJo+5(%2E%8WBgtEmX?W>+XmSe} zy>W)OyVEg>e=vO%8+UY}j37+XXEA0Qy^f5s45ClV><~%%f)od1WdcGNH!IRFkyq74-yTv069dfq!Qv&< z-yvz#z*F{~1v{6TAD+;PkXmI3r3QemGV+yq|Gc)(D6#*>?Tn|No{VvKy+8i^k4?hK Y7ihZ((T)-;JOBUy07*qoM6N<$g8LUF5C8xG diff --git a/storage/leveldb/icons/leveldb.png b/storage/leveldb/icons/leveldb.png new file mode 100644 index 0000000000000000000000000000000000000000..55760c7dc1b4c492ec0524b35a98e265c967a3f8 GIT binary patch literal 1676 zcmV;726Op|P)C3<00001b5ch_0Itp) z=>Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_000IbNklhRH=yf2SP$14C0}xjX>&0C6Ex0 zsvz-@_^6Z=K}!GuRf`aj8l?eBf&+10j_o+{_z~OV8PDA3*{dI8$BvmhelU)Nn*Dk1 z-RG{e&pK=Edw?@>CVs#n^G!IogBP54IT`~GE2_^%{i#nWBVQ_3%2T5Uc7LR;VWs525k9fd)#kJM zNZ_$wl_Zs<(ipOH7hl@{Z*Dx%!;7-Rtlk8b(G<5Bqpy;DD6}%Zr&~OmO!sqRKBLiv z0(0~FzABvputKO(3m^+%17BZJ)dwbXtRkmfq6wg;5!;j1@Kia}y_>%xHP*R{7Iki1 zidR~{v@A*FM)0^AdWD%GrPQP%RDdQDMX=<8E4hsXF1ngj!q^!eQssLiz1Z7wnXG){ z0siggN735Siq#sx@?6;zPvR;FBLE>HvVh~K^gV86$0BxP-l;jN`X|rUhi9$K z{6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{CwPaosQ(q!+l9xxJ-iHNKf>O~a-8rTy{D6rKpubH3={|s6!Nto(*OVg{z*hZR7l6wmAh(HK@^6++2@#(h*|`E z03i^p1glgcViU{w0Je5oh+0_K2tI)}78c?gq!1-fppe4G&elRnAznH8Y-Y#Vli73j z$whF%z|5MRWYNT`Qc6O75uH(v10)3`iz|YLz01Lo(U>VqnYtwxb;8(jiL}viLR)SqD1S78h0gQn!z`a63fA^_p)z^KP ztEWoPRNA)M6#TZ38nckHwYMK?4KOY25eQ8(I4au(9s{?_>Cc9%ou8g)+k~HL-Q{61=-P7R|cnW{4^}J*Ip`Qny4}|wx{Lt-# zv@d(rPwM@w{`K8%RH>Q!0zS#ccQaT_K7bmeOFf0XQ-J%lM1gfR-7dyroZ15Ln}~6Z z+D-C)uLf3?^(2{GCdC`pY!nGL@6XgJmh;&3u*I_BAKQNuaO0o>=Os;z9OFp+aGa0| utOA=c*tsO*3>act2d+oSe5`0S0Q>=5%9G-Z;1P!a0000 Date: Sat, 7 Jun 2014 08:31:34 +0100 Subject: [PATCH 18/20] resize a couple of icons --- social/xmpp/icons/xmpp.png | Bin 2358 -> 1042 bytes time/icons/sun.png | Bin 383 -> 581 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/social/xmpp/icons/xmpp.png b/social/xmpp/icons/xmpp.png index 57e43fc43f1ed502352dcb68468a080d340483dd..636847e38011ca4a10791d5457c84a5da2f63bf1 100644 GIT binary patch delta 997 zcmV{>iDO>$jBD}^0l=!EG#ViXW@;Fjllct zmDm-((B|gm6(ZU;vwb33nw_1!69mDpmlgNkKhtivuZ3aw9uZwL;Ce7NHg-TnzY)<3 zMNxdJs)r)-9e_IkR*C2yGwUGHgM$N%j*gC**@BtPsp{PL`1n+w=V0cNe~3;90NU;L z=KvN(1QQbz6a)d7xiqsb5iK(F_k$o=mIY?E1K;5=1GjqfMKtx}jUPz0g001T;REe!Y0OuTn zAb_ei%*=?0i3mxO7!eUOf3E@nx7%&BTCGE7zRk>>=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1{_2 tvG+a$aL^d@R;^a^xF{FpqWpizzX2O#aoGg`T1Ef>002ovPDHLkV1lu!R7d~- diff --git a/time/icons/sun.png b/time/icons/sun.png index c4918e5621be46bb2484c7430a498b7e17341648..6e4daba46c8be583daf855f64ce7dc586c9ab304 100644 GIT binary patch delta 552 zcmV+@0@wZj0>uO&iBL{Q4GJ0x0000DNk~Le0000P0000P2nGNE0L1BqW04^i3I729 z0RN!9r<0LD7k>Z;bV*G`2i^t-3NRV?ab{)!00G5GL_t(Y$L*CdYg9oLh0j@{7&IU# zTBQ*JVqqbYE@0s=NMS@Q1S<MeBBqGg*`@FYBoHDJJ5!1QK?7C`=d;+^ zWqeuLeVaeNI>mpDB%1(9Hrx1hihuL7BwN7KG4{V3@5xCd-LQQZ z=q9;+l57D3b4liab3+o_?*U0d(sq&uC*XMn9N9hsUe_caY^!`@`}veve3bOWHh^q1 zBmwL`%TK_Pt^<#oo7g^(v?J+YgeYE0xH*kqnFT(NHOG1(! za0u)Hi<4}!FnAjCPO@5+;TQ@bz-kdpo%zDB>v*i#sN^vtybZ)j)>^CIM1KW}=*q)Vi&n5DC z+gBug2QEw6E#2xiebVRiE!(@}gwSP5lOWbM%V&K60000<{9 z008+zyMK{D7k>c~Nklu_ZN24M*XsaUJ@(vHx>>m^hO zCE+I+IQY9DA>uqg$5t>#Q4~c{3{nG-sTTc8D`RK~fHllkNAh zvC>F56pOj*0iH_E`s|W$ClqJ6CzjMyQpoHwNt_*Df`4}Ihtfh0nZTPTN-`r^k!(qJ zB){(2y7$>0t(lX2a2^kmxs;HK>!_xhqsNR_1{Tyzqn;At6*Cr;;7HUV-v{uy(Vuu% z^XG=uz60n&v&&AjTC?%dYho>r(B;at=Ubo`t^hvKp@#wPRUtGXiZxe=Qb`0s#Z zXNBVxuga;!D2k#eiW1=m$I8L_cFqeA00000NkvXXu0mjfO&gcm From 94d19b2a41b77d4f1a3141de2d20a02720469587 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 9 Jun 2014 08:12:34 +0100 Subject: [PATCH 19/20] Update rawserial (roughly) in line with main serial node. (Now has binary and timout modes) --- io/rawserial/26-rawserial.html | 42 ++++++++++++++++++++++----- io/rawserial/26-rawserial.js | 52 +++++++++++++++++++++++++++------- 2 files changed, 77 insertions(+), 17 deletions(-) diff --git a/io/rawserial/26-rawserial.html b/io/rawserial/26-rawserial.html index c7b7c362..5bf3a7e3 100644 --- a/io/rawserial/26-rawserial.html +++ b/io/rawserial/26-rawserial.html @@ -16,17 +16,43 @@ diff --git a/io/rawserial/26-rawserial.js b/io/rawserial/26-rawserial.js index da53dfe8..11762005 100644 --- a/io/rawserial/26-rawserial.js +++ b/io/rawserial/26-rawserial.js @@ -29,25 +29,57 @@ if (!plat.match(/^win/)) { function RawSerialInNode(n) { RED.nodes.createNode(this,n); this.port = n.port; - this.split = n.split||null; - if (this.split == '\\n') this.split = "\n"; - if (this.split == '\\r') this.split = "\r"; + this.splitc = n.splitc||null; + this.out = n.out||"char"; + this.bin = n.bin||false; + if (this.splitc == '\\n') this.splitc = "\n"; + if (this.splitc == '\\r') this.splitc = "\r"; + if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } + console.log("Split is",this.out,this.splitc); var node = this; var setupSerial = function() { node.inp = fs.createReadStream(pre+node.port); node.log("opened "+pre+node.port); - node.inp.setEncoding('utf8'); + node.tout = null; var line = ""; + var buf = new Buffer(32768); + var i = 0; node.inp.on('data', function (data) { - if (node.split != null) { - if (data == node.split) { - node.send({payload:line}); - line = ""; + for (var z = 0; z < data.length; z++) { + if ((node.out === "time") && (node.splitc != 0)) { + if (node.tout) { + i += 1; + buf[i] = data[z]; + } + else { + node.tout = setTimeout(function () { + node.tout = null; + var m = new Buffer(i+1); + buf.copy(m,0,0,i+1); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload": m}); + }, node.splitc); + i = 0; + buf[0] = data[z]; + } + } + else if ((node.out == "char") && (node.splitc != null)) { + buf[i] = data[z]; + i += 1; + if ((data[z] === node.splitc.charCodeAt(0)) || (i === 32768)) { + var m = new Buffer(i); + buf.copy(m,0,0,i); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload":m}); + i = 0; + } + } + else { + if (node.bin !== "true") { node.send({"payload": String.fromCharCode(data[z])}); } + else { node.send({"payload": new Buffer([data[z]])});} } - else { line += data; } } - else { node.send({payload:data}); } }); //node.inp.on('end', function (error) {console.log("End", error);}); node.inp.on('close', function (error) { From 9b487098ae5a0c77350876f366ab8eabc2f8e359 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 10 Jun 2014 22:28:06 +0100 Subject: [PATCH 20/20] Tidy up rawserial node logging --- io/rawserial/26-rawserial.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/io/rawserial/26-rawserial.js b/io/rawserial/26-rawserial.js index 11762005..0a991fed 100644 --- a/io/rawserial/26-rawserial.js +++ b/io/rawserial/26-rawserial.js @@ -35,12 +35,11 @@ function RawSerialInNode(n) { if (this.splitc == '\\n') this.splitc = "\n"; if (this.splitc == '\\r') this.splitc = "\r"; if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } - console.log("Split is",this.out,this.splitc); var node = this; var setupSerial = function() { node.inp = fs.createReadStream(pre+node.port); - node.log("opened "+pre+node.port); + node.log("open "+pre+node.port); node.tout = null; var line = ""; var buf = new Buffer(32768); @@ -83,14 +82,14 @@ function RawSerialInNode(n) { }); //node.inp.on('end', function (error) {console.log("End", error);}); node.inp.on('close', function (error) { - util.log("[rawserial] "+node.port+" closed"); + node.log(node.port+" closed"); node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); }); node.inp.on('error', function(error) { - if (error.code == "ENOENT") { util.log("[rawserial] port "+node.port+" not found"); } - else { util.log("[rawserial] "+node.port+" error "+error); } + if (error.code == "ENOENT") { node.log(node.port+" not found"); } + else { node.log(node.port+" error "+error); } node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); @@ -119,18 +118,18 @@ function RawSerialOutNode(n) { node.oup.write(msg.payload); } }); - node.oup.on('open', function (error) { util.log("[rawserial] opened "+node.port); }); - node.oup.on('end', function (error) { console.log("End",error); }); + node.oup.on('open', function (error) { node.log("opened "+node.port); }); + node.oup.on('end', function (error) { node.log("end :"+error); }); node.oup.on('close', function (error) { - util.log("[rawserial] "+node.port+" closed"); + node.log(node.port+" closed"); node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); }); node.oup.on('error', function(error) { - if (error.code == "EACCES") { util.log("[rawserial] can't access port "+node.port); } - else if (error.code == "EIO") { util.log("[rawserial] can't write to port "+node.port); } - else { util.log("[rawserial] "+node.port+" error "+error); } + if (error.code == "EACCES") { node.log("can't access port "+node.port); } + else if (error.code == "EIO") { node.log("can't write to port "+node.port); } + else { node.log(node.port+" error "+error); } node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime);