mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 05:06:39 +01:00
finetuning C6 flashing, automatic retry on failing download
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -121,7 +121,7 @@ bool downloadAndWriteBinary(String &filename, const char *url) {
|
||||
HTTPClient binaryHttp;
|
||||
Serial.println(url);
|
||||
binaryHttp.begin(url);
|
||||
|
||||
binaryHttp.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
||||
int binaryResponseCode = binaryHttp.GET();
|
||||
Serial.println(binaryResponseCode);
|
||||
if (binaryResponseCode == HTTP_CODE_OK) {
|
||||
@@ -129,14 +129,26 @@ bool downloadAndWriteBinary(String &filename, const char *url) {
|
||||
if (file) {
|
||||
wsSerial("downloading " + String(filename));
|
||||
WiFiClient *stream = binaryHttp.getStreamPtr();
|
||||
uint8_t buffer[128];
|
||||
uint8_t buffer[256];
|
||||
size_t totalBytesRead = 0;
|
||||
while (stream->available()) {
|
||||
size_t bytesRead = stream->readBytes(buffer, sizeof(buffer));
|
||||
file.write(buffer, bytesRead);
|
||||
totalBytesRead += bytesRead;
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
}
|
||||
file.close();
|
||||
binaryHttp.end();
|
||||
return true;
|
||||
|
||||
file = contentFS->open(filename, "r");
|
||||
if (file) {
|
||||
if (totalBytesRead == file.size() && file.size() > 0) {
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
wsSerial("Download failed, " + String(file.size()) + " bytes");
|
||||
file.close();
|
||||
}
|
||||
} else {
|
||||
wsSerial("file open error " + String(filename));
|
||||
}
|
||||
@@ -167,8 +179,16 @@ bool doC6flash(uint8_t doDownload) {
|
||||
for (JsonObject obj : jsonArray) {
|
||||
String filename = "/" + obj["filename"].as<String>();
|
||||
String binaryUrl = "https://raw.githubusercontent.com/jjwbruijn/OpenEPaperLink/master/binaries/ESP32-C6" + String(filename);
|
||||
if (!downloadAndWriteBinary(filename, binaryUrl.c_str())) {
|
||||
return false;
|
||||
for (int retry = 0; retry < 10; retry++) {
|
||||
if (downloadAndWriteBinary(filename, binaryUrl.c_str())) {
|
||||
break;
|
||||
}
|
||||
wsSerial("Retry " + String(retry));
|
||||
if (retry < 9) {
|
||||
delay(1000);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,10 +596,10 @@ void rxSerialTask2(void* parameter) {
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
|
||||
time_t currentTime = millis();
|
||||
if (currentTime - startTime >= 2000) {
|
||||
if (charCount > 2000) {
|
||||
if (currentTime - startTime >= 1000) {
|
||||
if (charCount > 6000) {
|
||||
rxSerialStopTask2 = true;
|
||||
Serial.println("Serial monitor stopped because of flooding");
|
||||
Serial.println("Serial monitor stopped because of flooding (" + String(charCount) + " characters per second");
|
||||
}
|
||||
startTime = currentTime;
|
||||
charCount = 0;
|
||||
|
||||
@@ -226,7 +226,7 @@ to save file system space">
|
||||
<div id="releasetable"></div>
|
||||
<div>
|
||||
<div id="rollbackOption" style="display:none"><button id="rollbackBtn">Rollback to previous firmware</button></div>
|
||||
<div id="updateC6Option"><button id="updateC6Btn">Update ESP32-C6</button> <input type="checkbox" value="1" checked id="c6download"> download latest version</div>
|
||||
<span id="c6Option"><div id="updateC6Option"><button id="updateC6Btn">!! Update ESP32-C6</button> <input type="checkbox" value="1" checked id="c6download"> download latest version</div></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -571,6 +571,10 @@ ul.messages li.new {
|
||||
background-color: #a0a0a0;
|
||||
}
|
||||
|
||||
#c6Option {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.console {
|
||||
width: 100%;
|
||||
background-color: black;
|
||||
|
||||
@@ -50,6 +50,7 @@ export async function initUpdate() {
|
||||
currentVer = data.buildversion;
|
||||
currentBuildtime = data.buildtime;
|
||||
if (data.rollback) $("#rollbackOption").style.display = 'block';
|
||||
if (data.env == 'ESP32_S3_16_8_YELLOW_AP') $("#c6Option").style.display = 'block';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user