From 0de6b53ecc875b8b9b8fb792b56a2b52b6b46fb2 Mon Sep 17 00:00:00 2001 From: Paul Kendall Date: Sat, 9 Jul 2022 12:40:02 +1200 Subject: [PATCH] Allow passing of mode to main function --- ESPLoader.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ESPLoader.js b/ESPLoader.js index 6dfd655..5ba3cc0 100644 --- a/ESPLoader.js +++ b/ESPLoader.js @@ -933,7 +933,7 @@ class ESPLoader { } _connect_attempt = async ({mode='default_reset', esp32r0_delay=false} = {}) => { - console.log("_connect_attempt " + esp32r0_delay); + console.log("_connect_attempt " + mode + " " + esp32r0_delay); if (mode !== 'no_reset') { await this.transport.setDTR(false); await this.transport.setRTS(true); @@ -992,11 +992,11 @@ class ESPLoader { this.write_char('Connecting...'); await this.transport.connect(); for (i = 0 ; i < attempts; i++) { - resp = await this._connect_attempt({esp32r0_delay:false}); + resp = await this._connect_attempt({mode:mode, esp32r0_delay:false}); if (resp === "success") { break; } - resp = await this._connect_attempt({esp32r0_delay:true}); + resp = await this._connect_attempt({mode:mode, esp32r0_delay:true}); if (resp === "success") { break; } @@ -1023,8 +1023,8 @@ class ESPLoader { } - detect_chip = async () => { - await this.connect(); + detect_chip = async ({mode='default_reset'} = {}) => { + await this.connect({mode:mode}); this.write_char("Detecting chip type... "); if (this.chip != null) { this.log(this.chip.CHIP_NAME); @@ -1377,8 +1377,8 @@ class ESPLoader { } } - main_fn = async () => { - await this.detect_chip(); + main_fn = async ({mode='default_reset'} = {}) => { + await this.detect_chip({mode:mode}); if (this.chip == null) { this.log("Error in connecting to board"); return;