From 71f9d3ad989a5d18fdda7d5edf6f97fda38bf27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Mon, 14 Mar 2016 16:24:22 -0400 Subject: [PATCH 1/2] node-red-node-physical-web: Added uid mode --- hardware/physical-web/physical-web.html | 29 +++++++++++++++++ hardware/physical-web/physical-web.js | 42 ++++++++++++++++++++----- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/hardware/physical-web/physical-web.html b/hardware/physical-web/physical-web.html index 38e185fa..fb89326f 100644 --- a/hardware/physical-web/physical-web.html +++ b/hardware/physical-web/physical-web.html @@ -78,12 +78,27 @@ diff --git a/hardware/physical-web/physical-web.js b/hardware/physical-web/physical-web.js index 576bb84e..be556d45 100644 --- a/hardware/physical-web/physical-web.js +++ b/hardware/physical-web/physical-web.js @@ -23,9 +23,12 @@ module.exports = function(RED) { function Beacon(n) { RED.nodes.createNode(this,n); var node = this; + node.mode = n.mode; node.power = n.power; node.period = n.period * 10; node.url = n.url; + node.namespace = n.namespace; + node.instance = n.instance; node.options = { txPowerLevel: node.power, @@ -33,7 +36,7 @@ module.exports = function(RED) { tlmCount: 2 }; - if (node.url) { + if (node.mode === "url" && node.url) { if (!eddyBeacon) { eddyBeacon = true; try { @@ -46,13 +49,38 @@ module.exports = function(RED) { else {node.warn('Beacon already in use');} } + if (node.mode === "uid") { + if (!eddyBeacon) { + eddyBeacon = true; + try { + eddystoneBeacon.advertiseUid(node.namespace, node.instance, node.options); + node.status({fill:"green",shape:"dot",text:node.namespace}); + } catch(e) { + node.error('Error setting beacon information', e); + } + } + else {node.warn('Beacon already in use');} + } + node.on('input', function(msg) { - try { - eddystoneBeacon.advertiseUrl(msg.payload, node.options); - node.status({fill:"green",shape:"dot",text:node.url.toString()}); - } catch(e) { - node.status({fill:"red",shape:"circle",text:"URL too long"}); - node.error('error updating beacon URL', e); + if (node.mode === "url") { + try { + eddystoneBeacon.advertiseUrl(msg.payload, node.options); + node.status({fill:"green",shape:"dot",text:msg.payload}); + } catch(e) { + node.status({fill:"red",shape:"dot",text:"URL too long"}); + node.error('error updating beacon URL', e); + } + } + // uid mode + else { + try { + eddystoneBeacon.advertiseUid(msg.payload, msg.topic, node.options); + node.status({fill:"green",shape:"dot",text:msg.payload}); + } catch(e) { + node.status({fill:"red",shape:"dot",text:"Error setting beacon information"}); + node.error('Error setting beacon information', e); + } } }); From 6d41d33e806cdfd24040afe71722164bd44db118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Mon, 14 Mar 2016 17:30:50 -0400 Subject: [PATCH 2/2] node-red-node-physical-web: added documentation and exposed count property. --- hardware/physical-web/physical-web.html | 29 +++++++++++++++++++------ hardware/physical-web/physical-web.js | 5 +++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/hardware/physical-web/physical-web.html b/hardware/physical-web/physical-web.html index fb89326f..34852cb1 100644 --- a/hardware/physical-web/physical-web.html +++ b/hardware/physical-web/physical-web.html @@ -79,7 +79,7 @@ @@ -134,7 +147,8 @@ namespace: {value:""}, instance: {value:""}, power: {value:"-21",validate:RED.validators.number()}, - period: {value:"1",validate:RED.validators.number()} + period: {value:"10",validate:RED.validators.number()}, + count: {value:"2",validate:RED.validators.number()} }, color: "#2F7ACD", inputs:1, @@ -147,7 +161,8 @@ return this.name?"node_label_italic":""; }, oneditprepare: function() { - $( "#node-input-period" ).spinner({min:1}); + $( "#node-input-period" ).spinner({min:0}); + $( "#node-input-count" ).spinner({min:0}); $( "#node-input-power" ).spinner({min:-30,max:100}); $("#node-input-mode").on("change",function() { if ($("#node-input-mode").val() === "uid") { diff --git a/hardware/physical-web/physical-web.js b/hardware/physical-web/physical-web.js index be556d45..40b4f0fd 100644 --- a/hardware/physical-web/physical-web.js +++ b/hardware/physical-web/physical-web.js @@ -25,7 +25,8 @@ module.exports = function(RED) { var node = this; node.mode = n.mode; node.power = n.power; - node.period = n.period * 10; + node.period = n.period; + node.count = n.count; node.url = n.url; node.namespace = n.namespace; node.instance = n.instance; @@ -33,7 +34,7 @@ module.exports = function(RED) { node.options = { txPowerLevel: node.power, tlmPeriod: node.period, - tlmCount: 2 + tlmCount: node.count }; if (node.mode === "url" && node.url) {