Fix sensortag to still work with "old" tags ;-)

This commit is contained in:
dceejay 2015-07-02 13:29:13 +01:00
parent 91dc58d2b0
commit 6aa5500d34
3 changed files with 19 additions and 15 deletions

View File

@ -48,15 +48,15 @@
</script> </script>
<script type="text/x-red" data-help-name="sensorTag"> <script type="text/x-red" data-help-name="sensorTag">
<p>Input node for the Ti SensorTag</p> <p>Node to read from the Ti SensorTag</p>
<p>For this node to work correctly Node-Red needs to be run as <i>root</i> <p>For this node to work correctly on Linux, Node-Red needs to be run as
, this due to how Bluetooth 4.0 support is currently implemented in <i>root</i>, this due to how Bluetooth 4.0 support is currently implemented
Linux</p> in Linux.</p>
<p>The UUID field is the mac address of the sensor tag, this is optional <p>The UUID field is the bluetooth mac address of the sensor tag, this is optional
can be used to bind to a specific SensorTag if you have more than one and 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 active in range at the same time. <b>Note</b>: you can only have one SensorTag
per node-red instance at the moment)</p> per node-red instance at the moment.</p>
<p>The topic setting is a prefix that will be pre-pended to name of the <p>The topic setting is a prefix that will be pre-pended to the name of the
sensor that creates the reading. e.g. <i>sensorTag/temperature</i>. If sensor that creates the reading. e.g. <i>sensorTag/temperature</i>. If
blank it will be set to the UUID of the sensor tag.</p> blank it will be set to the UUID of the sensor tag.</p>
<p><strong>NOTE:</strong> Only 1 sensorTag can be read from at a time, <p><strong>NOTE:</strong> Only 1 sensorTag can be read from at a time,

View File

@ -89,7 +89,7 @@ module.exports = function(RED) {
msg.payload = {'left': left, 'right': right}; msg.payload = {'left': left, 'right': right};
node.send(msg); node.send(msg);
}); });
sensorTag.enableLuxometer(function() {});
sensorTag.on('luxometerChange', function(lux) { sensorTag.on('luxometerChange', function(lux) {
var msg = {'topic': node.topic + '/luxometer'}; var msg = {'topic': node.topic + '/luxometer'};
msg.payload = {'lux': parseInt(lux)}; msg.payload = {'lux': parseInt(lux)};
@ -142,10 +142,14 @@ module.exports = function(RED) {
} else { } else {
node.stag.unnotifyGyroscope(function() {}); node.stag.unnotifyGyroscope(function() {});
} }
if (node.luxometer) { if (node.stag.type === "cc2560") {
node.stag.notifyLuxometer(function() {}); if (node.luxometer) {
} else { node.stag.enableLuxometer(function() {});
node.stag.unnotifyLuxometer(function() {}); node.stag.notifyLuxometer(function() {});
} else {
node.stag.unnotifyLuxometer(function() {});
node.stag.disableLuxometer(function() {});
}
} }
if (node.keys) { if (node.keys) {
node.stag.notifySimpleKey(function() {}); node.stag.notifySimpleKey(function() {});

View File

@ -1,7 +1,7 @@
{ {
"name": "node-red-node-sensortag", "name": "node-red-node-sensortag",
"description": "A Node-RED node to read data from a TI SensorTag", "description": "A Node-RED node to read data from a TI SensorTag",
"version": "0.0.5", "version": "0.0.6",
"keywords" : ["node-red","sensortag"], "keywords" : ["node-red","sensortag"],
"dependencies": { "dependencies": {
"sensortag": "~1.0.1" "sensortag": "~1.0.1"