-
Notifications
You must be signed in to change notification settings - Fork 23
/
status.js
40 lines (34 loc) · 1.04 KB
/
status.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, sleep, PassageModeType } = 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 lock/unlock status");
console.log();
console.log();
const result = await lock.getLockStatus();
if (result != -1) {
if (result == 0) {
console.log("Lock is locked", result);
} else {
console.log("Lock is unlocked", result);
}
} else {
console.log("Failed to get lock status");
}
await lock.disconnect();
process.exit(0);
}
});
}
doStuff();