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;
|
||||
|
||||
try {
|
||||
logger('sending challenge to device');
|
||||
//logger('sending challenge to device');
|
||||
await this.characteristics.auth.WriteValue([0], {});
|
||||
logger('reading response from device');
|
||||
//logger('reading response from device');
|
||||
const challenge = await this.characteristics.auth.ReadValue({});
|
||||
const response = this._createChallengeResponse(this.cryptoKey, challenge);
|
||||
logger('responding to authenticate');
|
||||
const response = this._createChallengeResponse(this.cryptoKey, Buffer.from(challenge));
|
||||
//logger('responding to authenticate');
|
||||
await this.characteristics.auth.WriteValue([...response], {});
|
||||
|
||||
this.emit('authenticated');
|
||||
|
|
@ -346,7 +346,7 @@ class PlejdService extends EventEmitter {
|
|||
this.pingRef = setInterval(async () => {
|
||||
logger('ping');
|
||||
await this.ping();
|
||||
}, 5000);
|
||||
}, 3000);
|
||||
|
||||
await this.ping();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ async function main() {
|
|||
// init the BLE interface
|
||||
const plejd = new PlejdService(cryptoKey, true);
|
||||
plejd.on('connectFailed', () => {
|
||||
setTimeout(() => {
|
||||
console.log('plejd-ble: were unable to connect, will retry connection in 10 seconds.');
|
||||
setTimeout(() => {
|
||||
plejd.init();
|
||||
}, 10000);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue