1
+ // Note: Don't build & run this code with loglevel debug!
2
+ // It would crash for some unknown reason with stack canary error.
3
+
1
4
#if (USE_OTA)
2
5
3
6
/*
@@ -61,12 +64,9 @@ void start_ota_update() {
61
64
ota_display (1 , " **" , WIFI_SSID);
62
65
63
66
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);
67
68
WiFi.setHostname (host);
68
69
WiFi.mode (WIFI_STA);
69
- WiFi.begin ();
70
70
71
71
// Connect to WiFi network
72
72
// workaround applied here to bypass WIFI_AUTH failure
@@ -75,12 +75,12 @@ void start_ota_update() {
75
75
// 1st try
76
76
WiFi.begin (WIFI_SSID, WIFI_PASS);
77
77
while (WiFi.status () == WL_DISCONNECTED) {
78
- delay (500 );
78
+ delay (2000 );
79
79
}
80
80
// 2nd try
81
81
if (WiFi.status () != WL_CONNECTED) {
82
82
WiFi.begin (WIFI_SSID, WIFI_PASS);
83
- delay (500 );
83
+ delay (2000 );
84
84
}
85
85
86
86
uint8_t i = WIFI_MAX_TRY;
@@ -184,10 +184,11 @@ int do_ota_update() {
184
184
185
185
ESP_LOGI (TAG, " Requesting %s" , firmwarePath.c_str ());
186
186
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 ();
191
192
192
193
unsigned long timeout = millis ();
193
194
while (client.available () == 0 ) {
@@ -322,9 +323,10 @@ void ota_display(const uint8_t row, const std::string status,
322
323
dp->setCursor (14 * 8 , row * 8 );
323
324
dp->printf (status.substr (0 , 2 ).c_str ());
324
325
if (!msg.empty ()) {
326
+ dp->setCursor (0 , 7 * 8 );
325
327
dp->printf (" " );
328
+ dp->setCursor (0 , 7 * 8 );
326
329
dp->printf (msg.substr (0 , 16 ).c_str ());
327
- // dp->printf("\r\n");
328
330
}
329
331
dp_dump ();
330
332
#endif
@@ -334,7 +336,7 @@ void ota_display(const uint8_t row, const std::string status,
334
336
void show_progress (unsigned long current, unsigned long size) {
335
337
#ifdef HAS_DISPLAY
336
338
char buf[17 ];
337
- snprintf (buf, 17 , " %-9lu ( %3lu%%) " , current, current * 100 / size);
339
+ snprintf (buf, 17 , " %-9lu %3lu%%" , current, current * 100 / size);
338
340
ota_display (4 , " **" , buf);
339
341
#endif
340
342
}
0 commit comments