Skip to content

Commit 3af2f3d

Browse files
committed
ota.cpp: bugfix ota_display
1 parent ff51c31 commit 3af2f3d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/ota.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Note: Don't build & run this code with loglevel debug!
2+
// It would crash for some unknown reason with stack canary error.
3+
14
#if (USE_OTA)
25

36
/*
@@ -61,12 +64,9 @@ void start_ota_update() {
6164
ota_display(1, "**", WIFI_SSID);
6265

6366
WiFi.disconnect(true);
64-
WiFi.config(INADDR_NONE, INADDR_NONE,
65-
INADDR_NONE); // call is only a workaround for bug in WiFi class
66-
// see https://github.com/espressif/arduino-esp32/issues/806
67+
WiFi.mode(WIFI_MODE_NULL);
6768
WiFi.setHostname(host);
6869
WiFi.mode(WIFI_STA);
69-
WiFi.begin();
7070

7171
// Connect to WiFi network
7272
// workaround applied here to bypass WIFI_AUTH failure
@@ -75,12 +75,12 @@ void start_ota_update() {
7575
// 1st try
7676
WiFi.begin(WIFI_SSID, WIFI_PASS);
7777
while (WiFi.status() == WL_DISCONNECTED) {
78-
delay(500);
78+
delay(2000);
7979
}
8080
// 2nd try
8181
if (WiFi.status() != WL_CONNECTED) {
8282
WiFi.begin(WIFI_SSID, WIFI_PASS);
83-
delay(500);
83+
delay(2000);
8484
}
8585

8686
uint8_t i = WIFI_MAX_TRY;
@@ -184,10 +184,11 @@ int do_ota_update() {
184184

185185
ESP_LOGI(TAG, "Requesting %s", firmwarePath.c_str());
186186

187-
client.print(String("GET ") + firmwarePath + " HTTP/1.1\r\n");
188-
client.print(String("Host: ") + currentHost + "\r\n");
189-
client.print("Cache-Control: no-cache\r\n");
190-
client.print("Connection: close\r\n\r\n");
187+
client.println(String("GET " + firmwarePath + " HTTP/1.1"));
188+
client.println(String("Host: " + currentHost));
189+
client.println("Cache-Control: no-cache");
190+
client.println("Connection: close");
191+
client.println();
191192

192193
unsigned long timeout = millis();
193194
while (client.available() == 0) {
@@ -322,9 +323,10 @@ void ota_display(const uint8_t row, const std::string status,
322323
dp->setCursor(14 * 8, row * 8);
323324
dp->printf(status.substr(0, 2).c_str());
324325
if (!msg.empty()) {
326+
dp->setCursor(0, 7 * 8);
325327
dp->printf(" ");
328+
dp->setCursor(0, 7 * 8);
326329
dp->printf(msg.substr(0, 16).c_str());
327-
// dp->printf("\r\n");
328330
}
329331
dp_dump();
330332
#endif
@@ -334,7 +336,7 @@ void ota_display(const uint8_t row, const std::string status,
334336
void show_progress(unsigned long current, unsigned long size) {
335337
#ifdef HAS_DISPLAY
336338
char buf[17];
337-
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current * 100 / size);
339+
snprintf(buf, 17, "%-9lu %3lu%%", current, current * 100 / size);
338340
ota_display(4, "**", buf);
339341
#endif
340342
}

0 commit comments

Comments
 (0)