mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Merge pull request #33 from hardillb/master
Update the sidebar info for SensorTag node
This commit is contained in:
commit
508ad7c3af
@ -78,6 +78,14 @@
|
||||
<!-- The first <p> is used as the pop-up tool tip when hovering over a -->
|
||||
<!-- node in the palette. -->
|
||||
<p>Input node for the Ti SensorTag</p>
|
||||
<p>For this node to work correctly Node-Red needs to be run as root, this
|
||||
due to how Bluetooth 4.0 support is currently implemented in Linux</p>
|
||||
<p>The UUID field is the mac address of the sensor tag, this is optional
|
||||
can be used to bind to a specific SensorTag if you have more than one
|
||||
active in range at the same time. (note you can only have one SensorTag
|
||||
per node-red instance at the moment)</p>
|
||||
<p>The topic setting is a prefix that will be pre-pended to name of the
|
||||
sensor that creates the reading. e.g. <i>sensorTag/temperature</i></p>
|
||||
</script>
|
||||
|
||||
<!-- Finally, the node type is registered along with all of its properties -->
|
||||
@ -109,6 +117,7 @@
|
||||
},
|
||||
oneditsave: function() {
|
||||
var mac = $("#node-input-uuid").val();
|
||||
mac = mac.toLowerCase();
|
||||
//nasty hack as I can't get global replace to work
|
||||
mac = mac.replace(/:/gi,'');
|
||||
mac = mac.replace(/:/gi,'');
|
||||
|
@ -17,8 +17,6 @@
|
||||
// Require main module
|
||||
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) {
|
||||
@ -37,14 +35,14 @@ function sensorTagNode(n) {
|
||||
if (this.uuid === "") {
|
||||
this.uuid = undefined;
|
||||
}
|
||||
console.log(this.uuid);
|
||||
//console.log(this.uuid);
|
||||
|
||||
node=this;
|
||||
var node=this;
|
||||
|
||||
if ( typeof stag == "undefined") {
|
||||
if ( typeof node.stag == "undefined") {
|
||||
//console.log("starting");
|
||||
SensorTag.discover(function(sensorTag){
|
||||
stag = sensorTag;
|
||||
node.stag = sensorTag;
|
||||
sensorTag.connect(function(){
|
||||
//console.log("connected");
|
||||
sensorTag.discoverServicesAndCharacteristics(function(){
|
||||
@ -94,51 +92,51 @@ function sensorTagNode(n) {
|
||||
msg.payload = {'left': left, 'right': right};
|
||||
node.send(msg);
|
||||
});
|
||||
enable();
|
||||
enable(node);
|
||||
});
|
||||
});
|
||||
},node.uuid);
|
||||
} else {
|
||||
//console.log("reconfig");
|
||||
enable();
|
||||
enable(node);
|
||||
}
|
||||
}
|
||||
|
||||
function enable() {
|
||||
if (node.temperature) {
|
||||
stag.notifyIrTemperature(function(){});
|
||||
} else {
|
||||
stag.unnotifyIrTemperature(function(){});
|
||||
}
|
||||
if (node.pressure) {
|
||||
stag.notifyBarometricPressure(function(){});
|
||||
} else {
|
||||
stag.unnotifyBarometricPressure(function(){});
|
||||
}
|
||||
if (node.humidity) {
|
||||
stag.notifyHumidity(function() {});
|
||||
} else {
|
||||
stag.unnotifyHumidity(function() {});
|
||||
}
|
||||
if (node.accelometer){
|
||||
stag.notifyAccelerometer(function() {});
|
||||
} else {
|
||||
stag.unnotifyAccelerometer(function() {});
|
||||
}
|
||||
if (node.magnetometer) {
|
||||
stag.notifyMagnetometer(function() {});
|
||||
} else {
|
||||
stag.unnotifyMagnetometer(function() {});
|
||||
}
|
||||
if (node.gyroscope) {
|
||||
stag.notifyGyroscope(function() {});
|
||||
} else {
|
||||
stag.unnotifyGyroscope(function() {});
|
||||
}
|
||||
if (node.keys) {
|
||||
stag.notifySimpleKey(function() {});
|
||||
} else {
|
||||
stag.unnotifySimpleKey(function() {});
|
||||
}
|
||||
function enable(node) {
|
||||
if (node.temperature) {
|
||||
node.stag.notifyIrTemperature(function(){});
|
||||
} else {
|
||||
node.stag.unnotifyIrTemperature(function(){});
|
||||
}
|
||||
if (node.pressure) {
|
||||
node.stag.notifyBarometricPressure(function(){});
|
||||
} else {
|
||||
node.stag.unnotifyBarometricPressure(function(){});
|
||||
}
|
||||
if (node.humidity) {
|
||||
node.stag.notifyHumidity(function() {});
|
||||
} else {
|
||||
node.stag.unnotifyHumidity(function() {});
|
||||
}
|
||||
if (node.accelometer){
|
||||
node.stag.notifyAccelerometer(function() {});
|
||||
} else {
|
||||
node.stag.unnotifyAccelerometer(function() {});
|
||||
}
|
||||
if (node.magnetometer) {
|
||||
node.stag.notifyMagnetometer(function() {});
|
||||
} else {
|
||||
node.stag.unnotifyMagnetometer(function() {});
|
||||
}
|
||||
if (node.gyroscope) {
|
||||
node.stag.notifyGyroscope(function() {});
|
||||
} else {
|
||||
node.stag.unnotifyGyroscope(function() {});
|
||||
}
|
||||
if (node.keys) {
|
||||
node.stag.notifySimpleKey(function() {});
|
||||
} else {
|
||||
node.stag.unnotifySimpleKey(function() {});
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType("sensorTag",sensorTagNode);
|
||||
|
Loading…
Reference in New Issue
Block a user