From 801212ffb1b7cd2a485ff40ad998c96f92f13041 Mon Sep 17 00:00:00 2001 From: Ilya Kirov Date: Fri, 10 Jan 2025 22:31:16 +0300 Subject: [PATCH] fix: ZBOSS: fixed port reconnection processing during RESET (#1289) --- src/adapter/zboss/uart.ts | 7 ++++--- src/controller/controller.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/adapter/zboss/uart.ts b/src/adapter/zboss/uart.ts index 1b58708095..653e790083 100644 --- a/src/adapter/zboss/uart.ts +++ b/src/adapter/zboss/uart.ts @@ -38,6 +38,7 @@ export class ZBOSSUart extends EventEmitter { this.socketPort = undefined; this.writer = new ZBOSSWriter(); this.reader = new ZBOSSReader(); + this.reader.on('data', this.onPackage.bind(this)); this.queue = new Queue(1); this.waitress = new Waitress(this.waitressValidator, this.waitressTimeoutFormatter); } @@ -123,7 +124,6 @@ export class ZBOSSUart extends EventEmitter { this.writer.pipe(this.serialPort); this.serialPort.pipe(this.reader); - this.reader.on('data', this.onPackage.bind(this)); try { await this.serialPort.asyncOpen(); @@ -147,7 +147,6 @@ export class ZBOSSUart extends EventEmitter { this.writer.pipe(this.socketPort); this.socketPort.pipe(this.reader); - this.reader.on('data', this.onPackage.bind(this)); return await new Promise((resolve, reject): void => { const openError = async (err: Error): Promise => { @@ -311,7 +310,9 @@ export class ZBOSSUart extends EventEmitter { const waiter = this.waitFor(nextSeq); this.writeBuffer(data); logger.debug(`-?- waiting (${nextSeq})`, NS); - await waiter.start().promise; + if (!this.inReset) { + await waiter.start().promise; + } logger.debug(`-+- waiting (${nextSeq}) success`, NS); } else { this.writeBuffer(data); diff --git a/src/controller/controller.ts b/src/controller/controller.ts index d7e27817f9..915c2356ff 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -179,6 +179,7 @@ export class Controller extends events.EventEmitter { for (const device of Device.allIterator()) { device.removeFromDatabase(); } + Device.resetCache(); } if (startResult === 'reset' || (this.options.backupPath && !fs.existsSync(this.options.backupPath))) {