node-red-contrib-ibm-watson-iot
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -103,3 +103,3 @@ /** | ||
RED.nodes.registerType("ibmwiotp-credentials",IotDeviceNode, { | ||
RED.nodes.registerType("wiotp-credentials",IotDeviceNode, { | ||
credentials: { | ||
@@ -180,13 +180,4 @@ authToken: {type:"password"} | ||
} | ||
RED.nodes.registerType("ibmwiotp in", IotAppInNode); | ||
RED.nodes.registerType("wiotp in", IotAppInNode); | ||
function generateQuickstartId() { | ||
var id = ""; | ||
for (var i=0;i<6;i++) { | ||
var j = Math.floor(Math.random()*256); | ||
id += ((i>0 && i%2===0)?'-':'')+(j<16?'0':'')+j.toString(16); | ||
} | ||
return id.toUpperCase(); | ||
} | ||
function IotAppOutNode(n) { | ||
@@ -203,3 +194,2 @@ RED.nodes.createNode(this, n); | ||
this.credentials; | ||
if (!isQuickstart) { | ||
@@ -214,4 +204,4 @@ var deviceNode = RED.nodes.getNode(n.deviceKey); | ||
org: "quickstart", | ||
type: "node-red-ibmwiotp", | ||
id: n.qsDeviceId || generateQuickstartId() | ||
type: "node-red-wiotp", | ||
id: n.qsDeviceId || n.id | ||
} | ||
@@ -240,3 +230,3 @@ node.log("Connecting to Quickstart service as device "+this.credentials.type+"/"+this.credentials.id); | ||
if (Buffer.isBuffer(data)) { | ||
data = JSON.stringify({d:{value:data.toString()}}) | ||
data = JSON.stringify({d:{value:data.toString()}}); | ||
} else { | ||
@@ -268,3 +258,3 @@ if (typeof data === "object") { | ||
} else { | ||
data = JSON.stringify({d:{value:data}}) | ||
data = JSON.stringify({d:{value:data}}); | ||
} | ||
@@ -282,3 +272,3 @@ } | ||
} catch(err) { | ||
node.warn("Error sending message: "+err.toString(),msg) | ||
node.warn("Error sending message: "+err.toString(),msg); | ||
} | ||
@@ -293,5 +283,5 @@ }); | ||
} | ||
RED.nodes.registerType("ibmwiotp out", IotAppOutNode); | ||
RED.nodes.registerType("wiotp out", IotAppOutNode); | ||
}; |
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -28,3 +28,3 @@ "node-red", | ||
"nodes": { | ||
"ibmwiotp": "application/wiotp.js" | ||
"wiotp": "application/wiotp.js" | ||
} | ||
@@ -31,0 +31,0 @@ }, |
Sorry, the diff of this file is not supported yet
36328
263