'use strict';

const noble = require('noble');

const hardwareModules = new Set([
    require('./triones'),
]);

function createFor(peripheral) {
    for (let module of hardwareModules) {
        if (module.isCompatibleWith(peripheral.advertisement)) {
            // Stop scanning: some BT devices do not support
            // scanning and connecting to a peripheral at
            // the same time.
            noble.stopScanning();

            // connect to the device
            return module.createFor(peripheral);
        }
    }

    return Promise.resolve(null);
}

module.exports = {
    'createFor': createFor,
};
'use strict';

const hardwareModules = new Set([
    require('./triones'),
]);

function createFor(peripheral) {
    for (let module of hardwareModules) {
        if (module.isCompatibleWith(peripheral.advertisement)) {
            return module.createFor(peripheral);
        }
    }

    return Promise.resolve(null);
}

module.exports = {
    'createFor': createFor,
};
--- 
+++ 
@@ -1,4 +1,6 @@
 'use strict';
+
+const noble = require('noble');
 
 const hardwareModules = new Set([
     require('./triones'),
@@ -7,6 +9,12 @@
 function createFor(peripheral) {
     for (let module of hardwareModules) {
         if (module.isCompatibleWith(peripheral.advertisement)) {
+            // Stop scanning: some BT devices do not support
+            // scanning and connecting to a peripheral at
+            // the same time.
+            noble.stopScanning();
+
+            // connect to the device
             return module.createFor(peripheral);
         }
     }
Fix connecting to LE device not working on Linux
