-
Notifications
You must be signed in to change notification settings - Fork 23
/
getOperations.js
40 lines (33 loc) · 1.12 KB
/
getOperations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const { TTLockClient, LogOperateNames } = require('../dist');
const settingsFile = "lockData.json";
async function doStuff() {
let lockData = await require("./common/loadData")(settingsFile);
let options = require("./common/options")(lockData);
const client = new TTLockClient(options);
await client.prepareBTService();
client.startScanLock();
console.log("Scan started");
client.on("foundLock", async (lock) => {
console.log(lock.toJSON());
console.log();
if (lock.isInitialized() && lock.isPaired()) {
await lock.connect();
console.log("Trying to get Operations Log");
console.log();
console.log();
// make a copy so we don't save the record names
const results = JSON.parse(JSON.stringify(await lock.getOperationLog(true, true)));
await lock.disconnect();
for (let result of results) {
if (result) {
result.recordTypeName = LogOperateNames[result.recordType];
}
}
console.log(results);
await require("./common/saveData")(settingsFile, client.getLockData());
process.exit(0);
}
});
}
doStuff();