Revert back to arduino
It failed tests
This commit is contained in:
@@ -69,8 +69,8 @@ esphome:
|
|||||||
##### TYPE OF ESP BOARD #####
|
##### TYPE OF ESP BOARD #####
|
||||||
esp32:
|
esp32:
|
||||||
board: esp32dev
|
board: esp32dev
|
||||||
framework:
|
# framework:
|
||||||
type: esp-idf
|
# type: esp-idf
|
||||||
|
|
||||||
##### OTA PASSWORD #####
|
##### OTA PASSWORD #####
|
||||||
ota:
|
ota:
|
||||||
@@ -2202,14 +2202,21 @@ script:
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto upload_end_ = [&](bool retry) -> bool
|
auto upload_end_ = [&](bool completed) -> bool
|
||||||
{
|
{
|
||||||
static const char *const TAG = "script.upload_tft.upload_end_";
|
static const char *const TAG = "script.upload_tft.upload_end_";
|
||||||
|
ESP_LOGD(TAG, "Completed: %i", completed ? 1 : 0);
|
||||||
ESP_LOGD(TAG, "Restarting Nextion");
|
ESP_LOGD(TAG, "Restarting Nextion");
|
||||||
send_nextion_command("rest");
|
send_nextion_command("rest");
|
||||||
if (is_updating_) is_updating_ = not retry;
|
#ifdef ARDUINO
|
||||||
if (retry) ESP_LOGD(TAG, "Nextion TFT upload will try again");
|
delay(1500);
|
||||||
return not retry;
|
#elif defined(ESP_PLATFORM)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
is_updating_ = false;
|
||||||
|
if (!completed) ESP_LOGD(TAG, "Nextion TFT upload will try again");
|
||||||
|
return completed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ARDUINO // arduino # To do: Move to Nextion component on ESPHome
|
#ifdef ARDUINO // arduino # To do: Move to Nextion component on ESPHome
|
||||||
@@ -2351,7 +2358,7 @@ script:
|
|||||||
ESP_LOGD(TAG, "Connection failed");
|
ESP_LOGD(TAG, "Connection failed");
|
||||||
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
||||||
allocator.deallocate(transfer_buffer_, transfer_buffer_size_);
|
allocator.deallocate(transfer_buffer_, transfer_buffer_size_);
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Connected");
|
ESP_LOGD(TAG, "Connected");
|
||||||
}
|
}
|
||||||
@@ -2377,7 +2384,7 @@ script:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((code != 200 && code != 206) || tries > 5) {
|
if ((code != 200 && code != 206) || tries > 5) {
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String content_range_string = http.header("Content-Range");
|
String content_range_string = http.header("Content-Range");
|
||||||
@@ -2388,7 +2395,7 @@ script:
|
|||||||
|
|
||||||
if (content_length_ < 4096) {
|
if (content_length_ < 4096) {
|
||||||
ESP_LOGE(TAG, "Failed to get file size");
|
ESP_LOGE(TAG, "Failed to get file size");
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Updating Nextion");
|
ESP_LOGD(TAG, "Updating Nextion");
|
||||||
@@ -2426,7 +2433,7 @@ script:
|
|||||||
ESP_LOGD(TAG, "Preparation for tft update done");
|
ESP_LOGD(TAG, "Preparation for tft update done");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Preparation for tft update failed %d \"%s\"", response[0], response.c_str());
|
ESP_LOGD(TAG, "Preparation for tft update failed %d \"%s\"", response[0], response.c_str());
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nextion wants 4096 bytes at a time. Make chunk_size a multiple of 4096
|
// Nextion wants 4096 bytes at a time. Make chunk_size a multiple of 4096
|
||||||
@@ -2451,7 +2458,7 @@ script:
|
|||||||
|
|
||||||
if (!transfer_buffer_)
|
if (!transfer_buffer_)
|
||||||
{
|
{
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2466,7 +2473,7 @@ script:
|
|||||||
result = upload_by_chunks_arduino(&http, url, result);
|
result = upload_by_chunks_arduino(&http, url, result);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
ESP_LOGD(TAG, "Error updating Nextion!");
|
ESP_LOGD(TAG, "Error updating Nextion!");
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
App.feed_wdt();
|
App.feed_wdt();
|
||||||
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", ESP.getFreeHeap(), content_length_);
|
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", ESP.getFreeHeap(), content_length_);
|
||||||
@@ -2474,7 +2481,7 @@ script:
|
|||||||
is_updating_ = false;
|
is_updating_ = false;
|
||||||
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
||||||
|
|
||||||
return upload_end_(false);
|
return upload_end_(true);
|
||||||
};
|
};
|
||||||
#elif defined(ESP_PLATFORM) // esp-idf # To do: Move to Nextion component on ESPHome
|
#elif defined(ESP_PLATFORM) // esp-idf # To do: Move to Nextion component on ESPHome
|
||||||
auto upload_by_chunks_esp_idf = [&](const std::string &url, int range_start) -> int
|
auto upload_by_chunks_esp_idf = [&](const std::string &url, int range_start) -> int
|
||||||
@@ -2512,7 +2519,7 @@ script:
|
|||||||
|
|
||||||
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %d, retries(%d/10)", url.c_str(), status, tries);
|
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %d, retries(%d/10)", url.c_str(), status, tries);
|
||||||
tries++;
|
tries++;
|
||||||
delay(1000);
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tries > 10) {
|
if (tries > 10) {
|
||||||
@@ -2528,7 +2535,7 @@ script:
|
|||||||
while (fetched < range) {
|
while (fetched < range) {
|
||||||
int size = esp_http_client_get_content_length(client);
|
int size = esp_http_client_get_content_length(client);
|
||||||
if (!size) {
|
if (!size) {
|
||||||
delay(2);
|
vTaskDelay(pdMS_TO_TICKS(2));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int c = esp_http_client_read(client, reinterpret_cast<char*>(&transfer_buffer_[fetched]), size);
|
int c = esp_http_client_read(client, reinterpret_cast<char*>(&transfer_buffer_[fetched]), size);
|
||||||
@@ -2550,7 +2557,7 @@ script:
|
|||||||
|
|
||||||
if (!upload_first_chunk_sent_) {
|
if (!upload_first_chunk_sent_) {
|
||||||
upload_first_chunk_sent_ = true;
|
upload_first_chunk_sent_ = true;
|
||||||
delay(500);
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
}
|
}
|
||||||
|
|
||||||
recv_ret_string_(recv_string, 5000, true);
|
recv_ret_string_(recv_string, 5000, true);
|
||||||
@@ -2607,17 +2614,17 @@ script:
|
|||||||
|
|
||||||
int tries = 1;
|
int tries = 1;
|
||||||
int status = esp_http_client_perform(http);
|
int status = esp_http_client_perform(http);
|
||||||
delay(100);
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
while ((status != ESP_OK || (esp_http_client_get_status_code(http) != 200 && esp_http_client_get_status_code(http) != 206)) && tries <= 5) {
|
while ((status != ESP_OK || (esp_http_client_get_status_code(http) != 200 && esp_http_client_get_status_code(http) != 206)) && tries <= 5) {
|
||||||
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %d, retrying (%d/5)", url.c_str(), status, tries);
|
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %d, retrying (%d/5)", url.c_str(), status, tries);
|
||||||
delay(250);
|
vTaskDelay(pdMS_TO_TICKS(250));
|
||||||
status = esp_http_client_perform(http);
|
status = esp_http_client_perform(http);
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tries > 5) {
|
if (tries > 5) {
|
||||||
esp_http_client_cleanup(http);
|
esp_http_client_cleanup(http);
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int http_status = esp_http_client_get_status_code(http);
|
int http_status = esp_http_client_get_status_code(http);
|
||||||
@@ -2651,7 +2658,7 @@ script:
|
|||||||
|
|
||||||
if (content_length_ < 4096) {
|
if (content_length_ < 4096) {
|
||||||
ESP_LOGE(TAG, "File size check failed. Size: %d", content_length_);
|
ESP_LOGE(TAG, "File size check failed. Size: %d", content_length_);
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "File size check passed. Proceeding...");
|
ESP_LOGD(TAG, "File size check passed. Proceeding...");
|
||||||
}
|
}
|
||||||
@@ -2691,7 +2698,7 @@ script:
|
|||||||
ESP_LOGD(TAG, "Preparation for tft update done");
|
ESP_LOGD(TAG, "Preparation for tft update done");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Preparation for tft update failed %d \"%s\"", response[0], response.c_str());
|
ESP_LOGD(TAG, "Preparation for tft update failed %d \"%s\"", response[0], response.c_str());
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nextion wants 4096 bytes at a time. Make chunk_size a multiple of 4096
|
// Nextion wants 4096 bytes at a time. Make chunk_size a multiple of 4096
|
||||||
@@ -2715,7 +2722,7 @@ script:
|
|||||||
transfer_buffer_ = allocator.allocate(chunk_size);
|
transfer_buffer_ = allocator.allocate(chunk_size);
|
||||||
|
|
||||||
if (!transfer_buffer_) {
|
if (!transfer_buffer_) {
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2730,7 +2737,7 @@ script:
|
|||||||
result = upload_by_chunks_esp_idf(url, result);
|
result = upload_by_chunks_esp_idf(url, result);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
ESP_LOGD(TAG, "Error updating Nextion!");
|
ESP_LOGD(TAG, "Error updating Nextion!");
|
||||||
return upload_end_(true);
|
return upload_end_(false);
|
||||||
}
|
}
|
||||||
App.feed_wdt();
|
App.feed_wdt();
|
||||||
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", esp_get_free_heap_size(), content_length_);
|
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", esp_get_free_heap_size(), content_length_);
|
||||||
@@ -2738,20 +2745,29 @@ script:
|
|||||||
is_updating_ = false;
|
is_updating_ = false;
|
||||||
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
||||||
|
|
||||||
return upload_end_(false);
|
return upload_end_(true);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int upload_tries = 0;
|
unsigned int upload_tries = 0;
|
||||||
while (upload_tries < 5) {
|
while (upload_tries < 5) {
|
||||||
upload_tries++;
|
upload_tries++;
|
||||||
|
ESP_LOGD(TAG, "Try #%i", upload_tries);
|
||||||
if (upload_tft_(url, id(tf_uart).get_baud_rate())) id(restart_nspanel).press();
|
if (upload_tft_(url, id(tf_uart).get_baud_rate())) id(restart_nspanel).press();
|
||||||
ESP_LOGD(TAG, "Turn off Nextion");
|
ESP_LOGD(TAG, "Turn off Nextion");
|
||||||
id(screen_power).turn_off();
|
id(screen_power).turn_off();
|
||||||
|
#ifdef ARDUINO
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
#endif
|
||||||
ESP_LOGD(TAG, "Turn on Nextion");
|
ESP_LOGD(TAG, "Turn on Nextion");
|
||||||
id(screen_power).turn_on();
|
id(screen_power).turn_on();
|
||||||
|
#ifdef ARDUINO
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
unsigned int new_baud_rate;
|
unsigned int new_baud_rate;
|
||||||
if (id(tf_uart).get_baud_rate() == 115200) {
|
if (id(tf_uart).get_baud_rate() == 115200) {
|
||||||
@@ -2766,11 +2782,19 @@ script:
|
|||||||
ESP_LOGE(TAG, "TFT upload failed.");
|
ESP_LOGE(TAG, "TFT upload failed.");
|
||||||
ESP_LOGD(TAG, "Turn off Nextion");
|
ESP_LOGD(TAG, "Turn off Nextion");
|
||||||
id(screen_power).turn_off();
|
id(screen_power).turn_off();
|
||||||
|
#ifdef ARDUINO
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
#endif
|
||||||
ESP_LOGD(TAG, "Turn on Nextion");
|
ESP_LOGD(TAG, "Turn on Nextion");
|
||||||
id(screen_power).turn_on();
|
id(screen_power).turn_on();
|
||||||
ESP_LOGD(TAG, "Restarting esphome");
|
ESP_LOGD(TAG, "Restarting esphome");
|
||||||
|
#ifdef ARDUINO
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
#endif
|
||||||
id(restart_nspanel).press();
|
id(restart_nspanel).press();
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Finished!");
|
ESP_LOGD(TAG, "Finished!");
|
||||||
|
|||||||
Reference in New Issue
Block a user