Skip to content

Commit

Permalink
fix: ZBOSS: fixed port reconnection processing during RESET (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirovilya authored Jan 10, 2025
1 parent eb5b89c commit 801212f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/adapter/zboss/uart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, number>(this.waitressValidator, this.waitressTimeoutFormatter);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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<void> => {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class Controller extends events.EventEmitter<ControllerEventMap> {
for (const device of Device.allIterator()) {
device.removeFromDatabase();
}
Device.resetCache();
}

if (startResult === 'reset' || (this.options.backupPath && !fs.existsSync(this.options.backupPath))) {
Expand Down

0 comments on commit 801212f

Please sign in to comment.