Skip to content

Commit 75aaaab

Browse files
committed
update path to red.js to use environmnet variable
1 parent 5002542 commit 75aaaab

3 files changed

Lines changed: 35 additions & 44 deletions

File tree

hardware/digiRGB/78-digiRGB.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// Sample Node-RED node file
1818

1919
// Require main module
20-
var RED = require("../../red/red");
20+
var RED = require(process.env.NODE_RED_HOME+"/red/red");
2121
var HID = require('node-hid');
2222
var device;
2323
var node;
@@ -27,7 +27,7 @@ function DigiRGBNode(n) {
2727
// Create a RED node
2828
RED.nodes.createNode(this,n);
2929
node=this;
30-
30+
3131
var devices = HID.devices(0x16c0,0x05df);
3232
for (var i=0; i< devices.length; i++) {
3333
if (devices[i].product == 'DigiUSB') {
@@ -39,13 +39,13 @@ function DigiRGBNode(n) {
3939
} catch (e) {
4040
node.log(e)
4141
}
42-
}
42+
}
4343
}
44-
44+
4545
var p1 = /^\#[A-Fa-f0-9]{6}$/
4646
var p2 = /[0-9]+,[0-9]+,[0-9]+/
47-
48-
if (device) {
47+
48+
if (device) {
4949
this.on("input", function(msg) {
5050
if (msg != null) {
5151
if (p1.test(msg.payload)) {

hardware/scanBLE/101-scanBLE.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,52 @@
1919
**/
2020

2121
//might need to modify accordingly
22-
var RED = require("../../red/red");
22+
var RED = require(process.env.NODE_RED_HOME+"/red/red");
2323

2424
//import noble
2525
var noble = require('noble');
2626

2727
// The main node definition - most things happen in here
2828
function BleScan(n) {
29-
// Create a RED node
30-
RED.nodes.createNode(this,n);
29+
// Create a RED node
30+
RED.nodes.createNode(this,n);
3131

3232
var msg = {};
33-
var ble_name;
34-
var node = this;
35-
33+
var ble_name;
34+
var node = this;
35+
3636
//get name and uuid from user
3737
this.ble_name = n.ble_name;
3838
this.ble_uuid = n.ble_uuid;
3939

4040
this.on("input", function(msg){
41-
noble.startScanning();
41+
noble.startScanning();
4242
});
4343
noble.on('scanStart', function(msg) {
44-
var msg = {};
45-
msg.topic = node.topic;
46-
msg.payload = "Scanning initiated..." //debugging
47-
//console.log('scanning initiated...');
48-
node.send(msg);
44+
var msg = {};
45+
msg.topic = node.topic;
46+
msg.payload = "Scanning initiated..." //debugging
47+
//console.log('scanning initiated...');
48+
node.send(msg);
4949
});
5050

5151
noble.on('discover', function(peripheral) {
5252

53-
var msg = {};
54-
msg.topic = node.topic;
55-
msg.payload = "not found";
56-
57-
//check for the device name and the UUID (first one from the UUID list)
58-
if(peripheral.advertisement.localName==node.ble_name && peripheral.advertisement.serviceUuids[0]==node.ble_uuid) {
59-
msg.payload=peripheral.advertisement.localName;
60-
noble.stopScanning(); }
61-
node.send(msg);
53+
var msg = {};
54+
msg.topic = node.topic;
55+
msg.payload = "not found";
56+
57+
//check for the device name and the UUID (first one from the UUID list)
58+
if(peripheral.advertisement.localName==node.ble_name && peripheral.advertisement.serviceUuids[0]==node.ble_uuid) {
59+
msg.payload=peripheral.advertisement.localName;
60+
noble.stopScanning(); }
61+
node.send(msg);
6262
});
6363

64-
this.on("close", function() {
65-
try { noble.stopScanning(); }
66-
catch (err) { console.log(err); }
67-
});
64+
this.on("close", function() {
65+
try { noble.stopScanning(); }
66+
catch (err) { console.log(err); }
67+
});
6868
}
6969

7070
// Register the node by name. This must be called before overriding any of the

hardware/sensorTag/79-sensorTag.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@
1414
* limitations under the License.
1515
**/
1616

17-
// Sample Node-RED node file
18-
1917
// Require main module
20-
var RED = require("../../red/red");
18+
var RED = require(process.env.NODE_RED_HOME+"/red/red");
2119
var SensorTag = require('sensortag');
2220
var stag;
2321
var node;
2422

2523
// The main node definition - most things happen in here
2624
function sensorTagNode(n) {
27-
// Create a RED node
2825
RED.nodes.createNode(this,n);
2926
this.name = n.name;
3027
this.topic = n.topic;
@@ -36,16 +33,16 @@ function sensorTagNode(n) {
3633
this.gyroscope = n.gyroscope;
3734
this.keys = n.keys;
3835
node=this;
39-
36+
4037
if ( typeof stag == "undefined") {
4138
//console.log("starting");
42-
SensorTag.discover(function(sensorTag){
39+
SensorTag.discover(function(sensorTag){
4340
stag = sensorTag;
4441
sensorTag.connect(function(){
4542
//console.log("connected");
4643
sensorTag.discoverServicesAndCharacteristics(function(){
4744
sensorTag.enableIrTemperature(function(){});
48-
sensorTag.on('irTemperatureChange',
45+
sensorTag.on('irTemperatureChange',
4946
function(objectTemperature, ambientTemperature){
5047
var msg = {'topic': node.topic + '/tempature'};
5148
msg.payload = {'object': objectTemperature.toFixed(1),
@@ -98,8 +95,6 @@ function sensorTagNode(n) {
9895
//console.log("reconfig");
9996
enable();
10097
}
101-
102-
10398
}
10499

105100
function enable() {
@@ -139,8 +134,4 @@ function enable() {
139134
stag.unnotifySimpleKey(function() {});
140135
}
141136
}
142-
143-
// Register the node by name. This must be called before overriding any of the
144-
// Node functions.
145137
RED.nodes.registerType("sensorTag",sensorTagNode);
146-

0 commit comments

Comments
 (0)