mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Added a Bluetooth Logo to the library and linmk to it here. Renamed scan function to blescan (just in case). Added a close function to stop discovery, just to try to be clean.
This commit is contained in:
parent
cedc7a462a
commit
8b6dd4271b
@ -50,7 +50,7 @@
|
|||||||
},
|
},
|
||||||
inputs:1, // set the number of inputs - only 0 or 1
|
inputs:1, // set the number of inputs - only 0 or 1
|
||||||
outputs:1, // set the number of outputs - 0 to n
|
outputs:1, // set the number of outputs - 0 to n
|
||||||
icon: "arrow-in.png", // set the icon (held in public/icons)
|
icon: "bluetooth.png", // set the icon (held in public/icons)
|
||||||
label: function() { // sets the default label contents
|
label: function() { // sets the default label contents
|
||||||
return this.name||this.topic||"scanBLE";
|
return this.name||this.topic||"scanBLE";
|
||||||
},
|
},
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
//might need to modify accordingly
|
//might need to modify accordingly
|
||||||
var RED = require("../../red/red");
|
var RED = require("../../red/red");
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ var RED = require("../../red/red");
|
|||||||
var noble = require('noble');
|
var noble = require('noble');
|
||||||
|
|
||||||
// The main node definition - most things happen in here
|
// The main node definition - most things happen in here
|
||||||
function Scan(n) {
|
function BleScan(n) {
|
||||||
// Create a RED node
|
// Create a RED node
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
|
|
||||||
@ -62,15 +61,12 @@ function Scan(n) {
|
|||||||
node.send(msg);
|
node.send(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.on("close", function() {
|
||||||
|
try { noble.stopScanning(); }
|
||||||
|
catch (err) { console.log(err); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the node by name. This must be called before overriding any of the
|
// Register the node by name. This must be called before overriding any of the
|
||||||
// Node functions.
|
// Node functions.
|
||||||
RED.nodes.registerType("scanBLE", Scan);
|
RED.nodes.registerType("scanBLE", BleScan);
|
||||||
|
|
||||||
|
|
||||||
Scan.prototype.close = function() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user