Add support to CLI for multiple locks

parent 0f7fe3aa
......@@ -6,7 +6,14 @@ var augustctl = require('./index');
var config = require(process.env.AUGUSTCTL_CONFIG || './config.json');
var op = process.argv[2];
var whichLock = process.argv[2];
if ( config.hasOwnProperty(whichLock) ) {
config = config[whichLock];
} else {
throw new Error('invalid lock specified:' + whichLock);
}
var op = process.argv[3];
if (typeof augustctl.Lock.prototype[op] !== 'function') {
throw new Error('invalid operation: ' + op);
}
......
{
"front": {
"lockUuid": "abcdef012345",
"offlineKey": "ABCDEF0123456789ABCDEF0123456789",
"offlineKeyOffset": 1
},
"rear": {
"lockUuid": "abcdef456789",
"offlineKey": "ABCDEF0123456789ABCDEF0123456789",
"offlineKeyOffset": 1
}
}
......@@ -13,7 +13,7 @@ function scan(uuid) {
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
noble.startScanning([ Lock.BLE_COMMAND_SERVICE ]);
noble.startScanning([ Lock.BLE_COMMAND_SERVICE ], true);
} else {
noble.stopScanning();
}
......@@ -23,7 +23,6 @@ function scan(uuid) {
return new Promise(function(resolve) {
noble.on('discover', function(peripheral) {
if (uuid === undefined || peripheral.uuid === uuid) {
noble.stopScanning();
resolve(peripheral);
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment