optimization
This commit is contained in:
parent
dc6faaf07e
commit
85a194b794
2 changed files with 6 additions and 6 deletions
|
|
@ -294,12 +294,12 @@ class PlejdService extends EventEmitter {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger('sending challenge to device');
|
//logger('sending challenge to device');
|
||||||
await this.characteristics.auth.WriteValue([0], {});
|
await this.characteristics.auth.WriteValue([0], {});
|
||||||
logger('reading response from device');
|
//logger('reading response from device');
|
||||||
const challenge = await this.characteristics.auth.ReadValue({});
|
const challenge = await this.characteristics.auth.ReadValue({});
|
||||||
const response = this._createChallengeResponse(this.cryptoKey, challenge);
|
const response = this._createChallengeResponse(this.cryptoKey, Buffer.from(challenge));
|
||||||
logger('responding to authenticate');
|
//logger('responding to authenticate');
|
||||||
await this.characteristics.auth.WriteValue([...response], {});
|
await this.characteristics.auth.WriteValue([...response], {});
|
||||||
|
|
||||||
this.emit('authenticated');
|
this.emit('authenticated');
|
||||||
|
|
@ -346,7 +346,7 @@ class PlejdService extends EventEmitter {
|
||||||
this.pingRef = setInterval(async () => {
|
this.pingRef = setInterval(async () => {
|
||||||
logger('ping');
|
logger('ping');
|
||||||
await this.ping();
|
await this.ping();
|
||||||
}, 5000);
|
}, 3000);
|
||||||
|
|
||||||
await this.ping();
|
await this.ping();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ async function main() {
|
||||||
// init the BLE interface
|
// init the BLE interface
|
||||||
const plejd = new PlejdService(cryptoKey, true);
|
const plejd = new PlejdService(cryptoKey, true);
|
||||||
plejd.on('connectFailed', () => {
|
plejd.on('connectFailed', () => {
|
||||||
|
console.log('plejd-ble: were unable to connect, will retry connection in 10 seconds.');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log('plejd-ble: were unable to connect, will retry connection in 10 seconds.');
|
|
||||||
plejd.init();
|
plejd.init();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue