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))) {