Skip to content

Commit

Permalink
Fix rp2040 uf2 download url (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Aug 13, 2024
1 parent 809c74d commit af029d3
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions web.esphome.io/src/install-pico/install-pico-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { LitElement, html, css } from "lit";
import { customElement } from "lit/decorators.js";
import { LitElement, html, css, PropertyValues } from "lit";
import { customElement, state } from "lit/decorators.js";
import "@material/mwc-dialog";
import "@material/mwc-button";
import { esphomeDialogStyles } from "../../../src/styles";
import { picoPortFilters } from "../../../src/util/pico-port-filter";

const MANIFEST_URL = "https://firmware.esphome.io/esphome-web/manifest.json";
const DOWNLOAD_URL =
"https://firmware.esphome.io/esphome-web/pico-w/esphome-web-rp2040.uf2";
"https://firmware.esphome.io/esphome-web/{VERSION}/esphome-web-rp2040.uf2";

@customElement("esphome-install-pico-dialog")
class ESPHomeInstallPicoDialog extends LitElement {
public portSelectedCallback!: (port: SerialPort) => void;

@state() private _downloadUrl?: string;

public render() {
return html`
<mwc-dialog
Expand All @@ -33,7 +36,9 @@ class ESPHomeInstallPicoDialog extends LitElement {
</li>
<li>
Download
<a href=${DOWNLOAD_URL}>ESPHome for Pico</a>
${this._downloadUrl
? html`<a href=${this._downloadUrl}>ESPHome for Pico</a>`
: html`URL loading...`}
</li>
<li>
Drag the downloaded file to the RPI-RP2 USB drive. The installation
Expand All @@ -60,6 +65,24 @@ class ESPHomeInstallPicoDialog extends LitElement {
`;
}

protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
fetch(MANIFEST_URL)
.then(async (resp) => {
if (!resp.ok) {
alert(`Error loading manifest: ${resp.statusText}`);
this._close();
return;
}
const manifest = await resp.json();
this._downloadUrl = DOWNLOAD_URL.replace("{VERSION}", manifest.version);
})
.catch((err) => {
alert(`Error loading manifest: ${err.message}`);
this._close();
});
}

private async _continue() {
import("improv-wifi-serial-sdk/dist/serial-provision-dialog");
let port: SerialPort | undefined;
Expand Down

0 comments on commit af029d3

Please sign in to comment.