mirror of
https://github.com/esphome/esp-web-tools.git
synced 2025-07-27 13:46:50 +00:00
Allow configuring improv timeout (#139)
This commit is contained in:
parent
58c76e98bc
commit
ebef0688c8
12
index.html
12
index.html
@ -362,12 +362,22 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
By default a new installation will erase all data before installation.
|
By default a new installation will erase all data before installation.
|
||||||
If you want to leave this choice to the user, set the optional key
|
If you want to leave this choice to the user, set the optional manifest
|
||||||
|
key
|
||||||
<code>new_install_prompt_erase</code> to <code>true</code>. ESP Web
|
<code>new_install_prompt_erase</code> to <code>true</code>. ESP Web
|
||||||
Tools offers users a new installation if it is unable to detect the
|
Tools offers users a new installation if it is unable to detect the
|
||||||
current firmware of the device (via Improv Serial) or if the detected
|
current firmware of the device (via Improv Serial) or if the detected
|
||||||
firmware does not match the name specififed in the manifest.
|
firmware does not match the name specififed in the manifest.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
When a firmware is first installed on a device, it might need to do some
|
||||||
|
time consuming tasks like initializing the file system. By default ESP
|
||||||
|
Web Tools will wait 10 seconds to receive an Improv Serial response to
|
||||||
|
indicate that the boot is completed. You can increase this timeout by
|
||||||
|
setting the optional manifest key
|
||||||
|
<code>new_install_improv_wait_time</code> to the number of seconds to
|
||||||
|
wait. Set to <code>0</code> to disable Improv Serial detection.
|
||||||
|
</p>
|
||||||
<h2 id="improv">Configuring Wi-Fi</h2>
|
<h2 id="improv">Configuring Wi-Fi</h2>
|
||||||
<p>
|
<p>
|
||||||
ESP Web Tools supports the
|
ESP Web Tools supports the
|
||||||
|
@ -19,6 +19,8 @@ export interface Manifest {
|
|||||||
/** @deprecated use `new_install_prompt_erase` instead */
|
/** @deprecated use `new_install_prompt_erase` instead */
|
||||||
new_install_skip_erase?: boolean;
|
new_install_skip_erase?: boolean;
|
||||||
new_install_prompt_erase?: boolean;
|
new_install_prompt_erase?: boolean;
|
||||||
|
/* Time to wait to detect Improv Wi-Fi. Set to 0 to disable. */
|
||||||
|
new_install_improv_wait_time?: number;
|
||||||
builds: Build[];
|
builds: Build[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,18 +661,25 @@ class EwtInstallDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _fetchManifest() {
|
private async _initialize(justInstalled = false) {
|
||||||
if (this._manifest) {
|
if (this.port.readable === null || this.port.writable === null) {
|
||||||
return;
|
this._state = "ERROR";
|
||||||
|
this._error =
|
||||||
|
"Serial port is not readable/writable. Close any other application using it and try again.";
|
||||||
}
|
}
|
||||||
|
|
||||||
const manifestURL = new URL(
|
const manifestURL = new URL(
|
||||||
this.manifestPath,
|
this.manifestPath,
|
||||||
location.toString()
|
location.toString()
|
||||||
).toString();
|
).toString();
|
||||||
|
try {
|
||||||
this._manifest = await fetch(manifestURL).then(
|
this._manifest = await fetch(manifestURL).then(
|
||||||
(resp): Promise<Manifest> => resp.json()
|
(resp): Promise<Manifest> => resp.json()
|
||||||
);
|
);
|
||||||
|
} catch (err: any) {
|
||||||
|
this._state = "ERROR";
|
||||||
|
this._error = "Failed to download manifest";
|
||||||
|
}
|
||||||
if ("new_install_skip_erase" in this._manifest) {
|
if ("new_install_skip_erase" in this._manifest) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Manifest option "new_install_skip_erase" is deprecated. Use "new_install_prompt_erase" instead.'
|
'Manifest option "new_install_skip_erase" is deprecated. Use "new_install_prompt_erase" instead.'
|
||||||
@ -681,26 +688,25 @@ class EwtInstallDialog extends LitElement {
|
|||||||
this._manifest.new_install_prompt_erase = true;
|
this._manifest.new_install_prompt_erase = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async _initialize(justErased = false) {
|
if (this._manifest.new_install_improv_wait_time === 0) {
|
||||||
if (this.port.readable === null || this.port.writable === null) {
|
this._client = null;
|
||||||
this._state = "ERROR";
|
return;
|
||||||
this._error =
|
|
||||||
"Serial port is not readable/writable. Close any other application using it and try again.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const manifestProm = this._fetchManifest();
|
|
||||||
|
|
||||||
const client = new ImprovSerial(this.port!, this.logger);
|
const client = new ImprovSerial(this.port!, this.logger);
|
||||||
client.addEventListener("state-changed", () => {
|
client.addEventListener("state-changed", () => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
});
|
});
|
||||||
client.addEventListener("error-changed", () => this.requestUpdate());
|
client.addEventListener("error-changed", () => this.requestUpdate());
|
||||||
try {
|
try {
|
||||||
// If a device was just erased, the new firmware might need some time to
|
// If a device was just installed, give new firmware 10 seconds (overridable) to
|
||||||
// format the rest of the flash.
|
// format the rest of the flash and do other stuff.
|
||||||
const timeout = justErased ? 10000 : 1000;
|
const timeout = !justInstalled
|
||||||
|
? 1000
|
||||||
|
: this._manifest.new_install_improv_wait_time !== undefined
|
||||||
|
? this._manifest.new_install_improv_wait_time
|
||||||
|
: 10000;
|
||||||
this._info = await client.initialize(timeout);
|
this._info = await client.initialize(timeout);
|
||||||
this._client = client;
|
this._client = client;
|
||||||
client.addEventListener("disconnect", this._handleDisconnect);
|
client.addEventListener("disconnect", this._handleDisconnect);
|
||||||
@ -716,13 +722,6 @@ class EwtInstallDialog extends LitElement {
|
|||||||
this.logger.error("Improv initialization failed.", err);
|
this.logger.error("Improv initialization failed.", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await manifestProm;
|
|
||||||
} catch (err: any) {
|
|
||||||
this._state = "ERROR";
|
|
||||||
this._error = "Failed to download manifest";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _startInstall(erase: boolean) {
|
private _startInstall(erase: boolean) {
|
||||||
@ -745,7 +744,7 @@ class EwtInstallDialog extends LitElement {
|
|||||||
|
|
||||||
if (state.state === FlashStateType.FINISHED) {
|
if (state.state === FlashStateType.FINISHED) {
|
||||||
sleep(100)
|
sleep(100)
|
||||||
.then(() => this._initialize(this._installErase))
|
.then(() => this._initialize(true))
|
||||||
.then(() => this.requestUpdate());
|
.then(() => this.requestUpdate());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user