Skip to content

Commit

Permalink
revert back to old version, but with await
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobqvist committed Sep 21, 2021
1 parent 656dcb8 commit 00e559c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file.

import { sleep, Uint8Buffer, Uint8BufferSlipEncode, toByteArray, toHex } from "./util";
import { ESP32, Stub } from "./stubs";
import { sleep, toByteArray, toHex, Uint8Buffer, Uint8BufferSlipEncode } from "./util";

export enum ChipFamily {
ESP32 = "esp32",
Expand Down Expand Up @@ -119,18 +119,13 @@ export class EspLoader {
/**
* Start the read loop up.
*/
async connect(): Promise<void> {
async connect(rebootWaitMs = 1000): Promise<void> {
if (this.readLoopPromise) {
throw "already open";
}

await this.serialPort.setSignals({ dataTerminalReady: false });
await this.serialPort.setSignals({ requestToSend: true });
await sleep(100);
await this.serialPort.setSignals({ dataTerminalReady: true });
await this.serialPort.setSignals({ requestToSend: false });
await sleep(50);
await this.serialPort.setSignals({ dataTerminalReady: false });
await this.serialPort.setSignals({ dataTerminalReady: false, requestToSend: true });
await this.serialPort.setSignals({ dataTerminalReady: true, requestToSend: false });
await new Promise((resolve) => setTimeout(resolve, rebootWaitMs));
this._connect();
}

Expand Down

0 comments on commit 00e559c

Please sign in to comment.