Merge pull request #29 from pkendall64/mode-passing

Allow passing of mode to main function
This commit is contained in:
Adwait 2022-07-11 14:03:01 +05:30 committed by GitHub
commit 49c3278f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,7 +214,7 @@ class ESPLoader {
} }
_connect_attempt = async ({mode='default_reset', esp32r0_delay=false} = {}) => { _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') { if (mode !== 'no_reset') {
await this.transport.setDTR(false); await this.transport.setDTR(false);
await this.transport.setRTS(true); await this.transport.setRTS(true);
@ -273,11 +273,11 @@ class ESPLoader {
this.write_char('Connecting...'); this.write_char('Connecting...');
await this.transport.connect(); await this.transport.connect();
for (i = 0 ; i < attempts; i++) { 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") { if (resp === "success") {
break; break;
} }
resp = await this._connect_attempt({esp32r0_delay:true}); resp = await this._connect_attempt({mode:mode, esp32r0_delay:true});
if (resp === "success") { if (resp === "success") {
break; break;
} }
@ -303,8 +303,8 @@ class ESPLoader {
} }
detect_chip = async () => { detect_chip = async ({mode='default_reset'} = {}) => {
await this.connect(); await this.connect({mode:mode});
this.write_char("Detecting chip type... "); this.write_char("Detecting chip type... ");
if (this.chip != null) { if (this.chip != null) {
this.log(this.chip.CHIP_NAME); this.log(this.chip.CHIP_NAME);
@ -657,8 +657,8 @@ class ESPLoader {
} }
} }
main_fn = async () => { main_fn = async ({mode='default_reset'} = {}) => {
await this.detect_chip(); await this.detect_chip({mode:mode});
if (this.chip == null) { if (this.chip == null) {
this.log("Error in connecting to board"); this.log("Error in connecting to board");
return; return;