diff --git a/hardware/physical-web/package.json b/hardware/physical-web/package.json index df490c9e..c9572ddf 100644 --- a/hardware/physical-web/package.json +++ b/hardware/physical-web/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-physical-web", - "version": "0.0.3", + "version": "0.0.4", "description": "A set of nodes to interact with the Phyical Web", "main": "physical-web.js", "scripts": { diff --git a/hardware/physical-web/physical-web.html b/hardware/physical-web/physical-web.html index 66aabf89..e09d84e1 100644 --- a/hardware/physical-web/physical-web.html +++ b/hardware/physical-web/physical-web.html @@ -97,6 +97,8 @@
+ +

This URL needs to be shorter than 18 bytes in length to meet Eddystone spec


@@ -115,7 +117,7 @@ @@ -124,7 +126,9 @@ category: 'Physical_Web', // the palette category defaults: { // defines the editable properties of the node name: {value:"Eddystone"}, // along with default values. - url: {value: ""}, + url: {value: "" + //, validate: function(v) {var m = encodeURIComponent(v).match(/%[89ABab]/g); if (v.length + (m ? m.length : 0) < 18){$('#node-input-url-shorten').prop('disabled', true);return true} else {$('#node-input-url-shorten').prop('disabled', false);return false}} + }, power: {value:"-21"}, period: {value: "10"} }, @@ -138,6 +142,12 @@ }, labelStyle: function() { // sets the class to apply to the label return this.name?"node_label_italic":""; + }, + oneditprepare: function() { + + }, + oneditsave: function() { + } }); \ No newline at end of file diff --git a/hardware/physical-web/physical-web.js b/hardware/physical-web/physical-web.js index e3a20b88..e7b9716f 100644 --- a/hardware/physical-web/physical-web.js +++ b/hardware/physical-web/physical-web.js @@ -15,73 +15,74 @@ **/ module.exports = function(RED) { - "use strict"; + "use strict"; - var eddystoneBeacon = require('eddystone-beacon'); - var EddystoneBeaconScanner = require('eddystone-beacon-scanner'); + var eddystoneBeacon = require('eddystone-beacon'); + var EddystoneBeaconScanner = require('eddystone-beacon-scanner'); - function Beacon(n){ - RED.nodes.createNode(this,n); - var node = this; - node.power = n.power; - node.period = n.period; - node.url = n.url; + function Beacon(n){ + RED.nodes.createNode(this,n); + var node = this; + node.power = n.power; + node.period = n.period; + node.url = n.url; - node.options = { - txPowerLevel: node.power, - tlmPeriod: node.period - } + node.options = { + txPowerLevel: node.power, + tlmPeriod: node.period, + tlmCount: 2 + } - if (node.url) { - try { - eddystoneBeacon.advertiseUrl(msg.payload, node.options); - } catch(e){ - node.error('Error setting beacon URL', e); - } - } + if (node.url) { + try { + eddystoneBeacon.advertiseUrl(node.url, node.options); + } catch(e){ + node.error('Error setting beacon URL', e); + } + } - node.on('input', function(msg){ - try { - eddystoneBeacon.advertiseUrl(msg.payload, node.options); - } catch(e){ - node.error('error updating beacon URL', e); - } - }); + node.on('input', function(msg){ + try { + eddystoneBeacon.advertiseUrl(msg.payload, node.options); + } catch(e){ + node.error('error updating beacon URL', e); + } + }); - node.on('close', function(done){ - try { - eddystoneBeacon.stop(); - done(); - } catch(e){ - node.error('error shuttingdown beacon', e); - } - }); + node.on('close', function(done){ + try { + eddystoneBeacon.stop(); + done(); + } catch(e){ + node.error('error shuttingdown beacon', e); + } + }); - } - RED.nodes.registerType("PhysicalWeb out", Beacon); + } + RED.nodes.registerType("PhysicalWeb out", Beacon); - function Scanner(n){ - RED.nodes.createNode(this,n); - var node = this; - node.topic = n.topic; + function Scanner(n){ + RED.nodes.createNode(this,n); + var node = this; + node.topic = n.topic; - function onFound(beacon) { - node.send({ - topic: node.topic, - payload: beacon - }); - } + function onFound(beacon) { + node.send({ + topic: node.topic, + payload: beacon + }); + } - EddystoneBeaconScanner.on('found', onFound); - EddystoneBeaconScanner.on('updated', onFound); + EddystoneBeaconScanner.on('found', onFound); + EddystoneBeaconScanner.on('updated', onFound); - node.on('close',function(done){ - EddystoneBeaconScanner.removeListener('found', onFound); - EddystoneBeaconScanner.removeListener('updated', onFound); - done(); - }); - } - RED.nodes.registerType("PhysicalWeb in", Scanner); + node.on('close',function(done){ + EddystoneBeaconScanner.removeListener('found', onFound); + EddystoneBeaconScanner.removeListener('updated', onFound); + done(); + }); + } + RED.nodes.registerType("PhysicalWeb in", Scanner); -}; \ No newline at end of file +};