Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ring/teddycloud into develop
  • Loading branch information
SciLor committed Jul 29, 2024
2 parents 5e5950a + 5b85794 commit 2a9146c
Show file tree
Hide file tree
Showing 4 changed files with 900 additions and 20 deletions.
49 changes: 42 additions & 7 deletions contrib/data/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,8 @@ <h3>Encode to {this.props.path}</h3>
showDownload: false,
showFlash: false,
connected: false,
wifi_ssid: '',
wifi_pass: '',
hostname: window.location.hostname
};
this.fileInputRef = React.createRef();
Expand Down Expand Up @@ -1993,7 +1995,7 @@ <h3>Encode to {this.props.path}</h3>
} catch (err) {
this.setState({ state: `Failed to connect: ${err.message}`, connected: false });
alert(err.message);
await port.close();
this.state.port = null;
return;
}

Expand All @@ -2018,7 +2020,7 @@ <h3>Encode to {this.props.path}</h3>
this.setState({ state: `Failed to communicate: ${err.message}`, connected: false });
console.error(err);
alert(err.message);
await port.close();
this.state.port = null;
return;
}
};
Expand Down Expand Up @@ -2079,7 +2081,7 @@ <h3>Encode to {this.props.path}</h3>
} catch (err) {
this.setState({ state: `Failed to connect: ${err.message}`, connected: false });
alert(err.message);
await port.close();
this.state.port = null;
return;
}

Expand Down Expand Up @@ -2149,15 +2151,15 @@ <h3>Encode to {this.props.path}</h3>
this.setState({ state: `Failed to communicate: ${err.message}`, connected: false });
console.error(err);
alert(err.message);
await port.close();
this.state.port = null;
return;
}
}

async patchFlash() {
this.setState({ showProgress: false, showFlash: false });
this.setState({ state: `Patching flash image...` });
const response = await fetch(`/api/patchFirmware?filename=${this.state.filename}&hostname=${this.state.hostname}`, {
const response = await fetch(`/api/patchFirmware?filename=${this.state.filename}&hostname=${this.state.hostname}&wifi_ssid=${this.state.wifi_ssid}&wifi_pass=${this.state.wifi_pass}`, {
method: 'GET'
});
this.setState({ state: `Payload received` });
Expand Down Expand Up @@ -2194,7 +2196,7 @@ <h3>Encode to {this.props.path}</h3>
} catch (err) {
this.setState({ state: `Failed to connect: ${err.message}`, connected: false });
alert(err.message);
await port.close();
this.state.port = null;
return;
}

Expand Down Expand Up @@ -2236,7 +2238,7 @@ <h3>Encode to {this.props.path}</h3>
this.setState({ state: `Failed to communicate: ${err.message}`, connected: false });
console.error(err);
alert(err.message);
await port.close();
this.state.port = null;
return;
}

Expand Down Expand Up @@ -2310,6 +2312,7 @@ <h3>ESP32 box flashing</h3>

<div className="center-content">
{this.state.showDownload && (
<div>
<div>
<label>
TeddyCloud hostname:
Expand All @@ -2333,8 +2336,40 @@ <h3>ESP32 box flashing</h3>
}}
/>
</label>
</div>
<div>
<label>
WiFi SSID:
<input
type="text"
defaultValue=""
onChange={(e) => {
let value = e.target.value;
this.setState({
wifi_ssid: value
});
}}
/> (leave empty to skip patching)
</label>
</div>
<div>
<label>
WiFi Password:
<input
type="text"
defaultValue=""
onChange={(e) => {
let value = e.target.value;
this.setState({
wifi_pass: value
});
}}
/>
</label>

{this.state.warningText && <p style={{ color: '#CC3010' }}>{this.state.warningText}</p>}
</div>
</div>
)}

{/* Hidden file input to handle file selection */}
Expand Down
1 change: 1 addition & 0 deletions include/esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ error_t esp32_fat_inject(const char *firmware, const char *fat_path, const char
error_t esp32_inject_cert(const char *rootPath, const char *patchedPath, const char *mac);
error_t esp32_inject_ca(const char *rootPath, const char *patchedPath, const char *mac);
error_t esp32_patch_host(const char *patchedPath, const char *hostname, const char *oldrtnl, const char *oldapi);
error_t esp32_patch_wifi(const char *path, const char *ssid, const char *pass);

uint32_t mem_replace(uint8_t *buffer, size_t buffer_len, const char *pattern, const char *replace);
Loading

0 comments on commit 2a9146c

Please sign in to comment.