From 0e370c9bbc9d00ecee0fe8f944db8ac3d9a3f3df Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Thu, 7 Nov 2013 22:51:52 +0000 Subject: [PATCH 1/3] fixed typo in the temperature topic --- hardware/sensorTag/79-sensorTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/sensorTag/79-sensorTag.js b/hardware/sensorTag/79-sensorTag.js index 92555099..3953783b 100644 --- a/hardware/sensorTag/79-sensorTag.js +++ b/hardware/sensorTag/79-sensorTag.js @@ -47,7 +47,7 @@ function sensorTagNode(n) { sensorTag.enableIrTemperature(function(){}); sensorTag.on('irTemperatureChange', function(objectTemperature, ambientTemperature){ - var msg = {'topic': node.topic + '/tempature'}; + var msg = {'topic': node.topic + '/temperature'}; msg.payload = {'object': objectTemperature.toFixed(1), 'ambient':ambientTemperature.toFixed(1) }; From 8fbbd4d1fd5b8e7fcab4a3f04c99a812605070a3 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 22 Nov 2013 13:58:41 +0000 Subject: [PATCH 2/3] Added tag selection --- hardware/sensorTag/79-sensorTag.html | 7 ++++++- hardware/sensorTag/79-sensorTag.js | 28 +++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/hardware/sensorTag/79-sensorTag.html b/hardware/sensorTag/79-sensorTag.html index 5bcbb092..1ce0260f 100644 --- a/hardware/sensorTag/79-sensorTag.html +++ b/hardware/sensorTag/79-sensorTag.html @@ -33,9 +33,13 @@
- +
+
+ + +
@@ -85,6 +89,7 @@ defaults: { // defines the editable properties of the node name: {value:"sensorTag"}, // along with default values. topic: {value:"sensorTag"}, + uuid: {value:undefined}, temperature: {value:true}, humidity: {value:true}, pressure: {value:true}, diff --git a/hardware/sensorTag/79-sensorTag.js b/hardware/sensorTag/79-sensorTag.js index 3953783b..61dbc24b 100644 --- a/hardware/sensorTag/79-sensorTag.js +++ b/hardware/sensorTag/79-sensorTag.js @@ -14,20 +14,18 @@ * limitations under the License. **/ -// Sample Node-RED node file - // Require main module -var RED = require("../../red/red"); +var RED = require(process.env.NODE_RED_HOME+"/red/red"); var SensorTag = require('sensortag'); var stag; var node; // The main node definition - most things happen in here function sensorTagNode(n) { - // Create a RED node RED.nodes.createNode(this,n); this.name = n.name; this.topic = n.topic; + this.uuid = n.uuid; this.temperature = n.temperature; this.pressure = n.pressure; this.humidity = n.humidity; @@ -35,19 +33,25 @@ function sensorTagNode(n) { this.magnetometer = n.magnetometer; this.gyroscope = n.gyroscope; this.keys = n.keys; + + if (this.uuid === "") { + this.uuid = undefined; + } + console.log(this.uuid); + node=this; - + if ( typeof stag == "undefined") { //console.log("starting"); - SensorTag.discover(function(sensorTag){ + SensorTag.discover(function(sensorTag){ stag = sensorTag; sensorTag.connect(function(){ //console.log("connected"); sensorTag.discoverServicesAndCharacteristics(function(){ sensorTag.enableIrTemperature(function(){}); - sensorTag.on('irTemperatureChange', + sensorTag.on('irTemperatureChange', function(objectTemperature, ambientTemperature){ - var msg = {'topic': node.topic + '/temperature'}; + var msg = {'topic': node.topic + '/tempature'}; msg.payload = {'object': objectTemperature.toFixed(1), 'ambient':ambientTemperature.toFixed(1) }; @@ -93,13 +97,11 @@ function sensorTagNode(n) { enable(); }); }); - }); + },node.uuid); } else { //console.log("reconfig"); enable(); } - - } function enable() { @@ -139,8 +141,4 @@ function enable() { stag.unnotifySimpleKey(function() {}); } } - -// Register the node by name. This must be called before overriding any of the -// Node functions. RED.nodes.registerType("sensorTag",sensorTagNode); - From 6457ef0ca6c59e4ba19073849ed982df1f5aa251 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Sun, 24 Nov 2013 13:48:14 +0000 Subject: [PATCH 3/3] updated the readme now the standard sensortag node works and added a oneditsave to convert the mac address to the correct format --- hardware/sensorTag/79-sensorTag.html | 10 ++++++++++ hardware/sensorTag/README | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hardware/sensorTag/79-sensorTag.html b/hardware/sensorTag/79-sensorTag.html index 1ce0260f..19d21eb8 100644 --- a/hardware/sensorTag/79-sensorTag.html +++ b/hardware/sensorTag/79-sensorTag.html @@ -106,6 +106,16 @@ }, labelStyle: function() { // sets the class to apply to the label return this.name?"node_label_italic":""; + }, + oneditsave: function() { + var mac = $("#node-input-uuid").val(); + //nasty hack as I can't get global replace to work + mac = mac.replace(/:/gi,''); + mac = mac.replace(/:/gi,''); + mac = mac.replace(/:/gi,''); + mac = mac.replace(/:/gi,''); + mac = mac.toLowerCase(); + $("#node-input-uuid").val(mac); } }); diff --git a/hardware/sensorTag/README b/hardware/sensorTag/README index b524fc69..2d6657ab 100644 --- a/hardware/sensorTag/README +++ b/hardware/sensorTag/README @@ -1,5 +1,5 @@ -This currently requires a slightly modified sensortag library +This currently requires the sensortag library To install use the following command in the Node-Red directory -npm install sensortag@https://api.github.com/repos/hardillb/node-sensortag/tarball +npm install sensortag