mirror of
https://github.com/esphome/esphome.git
synced 2025-01-08 22:01:44 +01:00
[nextion] Exit reparse before update TFT (#6589)
This commit is contained in:
parent
989a64bdcf
commit
05fbb260ee
3 changed files with 25 additions and 3 deletions
|
@ -993,9 +993,13 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the tft file and soft reset Nextion
|
* Upload the tft file and soft reset Nextion
|
||||||
|
* @param exit_reparse If true, the function exits reparse mode before uploading the TFT file. This parameter
|
||||||
|
* defaults to true, ensuring that the display is ready to receive and apply the new TFT file without needing
|
||||||
|
* to manually reset or reconfigure. Exiting reparse mode is recommended for most upload scenarios to ensure
|
||||||
|
* the display properly processes the uploaded file command.
|
||||||
* @return bool True: Transfer completed successfuly, False: Transfer failed.
|
* @return bool True: Transfer completed successfuly, False: Transfer failed.
|
||||||
*/
|
*/
|
||||||
bool upload_tft();
|
bool upload_tft(bool exit_reparse = true);
|
||||||
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,9 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
||||||
return range_end + 1;
|
return range_end + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Nextion::upload_tft() {
|
bool Nextion::upload_tft(bool exit_reparse) {
|
||||||
ESP_LOGD(TAG, "Nextion TFT upload requested");
|
ESP_LOGD(TAG, "Nextion TFT upload requested");
|
||||||
|
ESP_LOGD(TAG, "Exit reparse: %s", YESNO(exit_reparse));
|
||||||
ESP_LOGD(TAG, "URL: %s", this->tft_url_.c_str());
|
ESP_LOGD(TAG, "URL: %s", this->tft_url_.c_str());
|
||||||
|
|
||||||
if (this->is_updating_) {
|
if (this->is_updating_) {
|
||||||
|
@ -157,6 +158,14 @@ bool Nextion::upload_tft() {
|
||||||
|
|
||||||
this->is_updating_ = true;
|
this->is_updating_ = true;
|
||||||
|
|
||||||
|
if (exit_reparse) {
|
||||||
|
ESP_LOGD(TAG, "Exiting Nextion reparse mode");
|
||||||
|
if (!this->set_protocol_reparse_mode(false)) {
|
||||||
|
ESP_LOGW(TAG, "Failed to request Nextion to exit reparse mode");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setTimeout(15000); // Yes 15 seconds.... Helps 8266s along
|
http.setTimeout(15000); // Yes 15 seconds.... Helps 8266s along
|
||||||
bool begin_status = false;
|
bool begin_status = false;
|
||||||
|
|
|
@ -160,8 +160,9 @@ int Nextion::upload_range(const std::string &url, int range_start) {
|
||||||
return range_end + 1;
|
return range_end + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Nextion::upload_tft() {
|
bool Nextion::upload_tft(bool exit_reparse) {
|
||||||
ESP_LOGD(TAG, "Nextion TFT upload requested");
|
ESP_LOGD(TAG, "Nextion TFT upload requested");
|
||||||
|
ESP_LOGD(TAG, "Exit reparse: %s", YESNO(exit_reparse));
|
||||||
ESP_LOGD(TAG, "url: %s", this->tft_url_.c_str());
|
ESP_LOGD(TAG, "url: %s", this->tft_url_.c_str());
|
||||||
|
|
||||||
if (this->is_updating_) {
|
if (this->is_updating_) {
|
||||||
|
@ -176,6 +177,14 @@ bool Nextion::upload_tft() {
|
||||||
|
|
||||||
this->is_updating_ = true;
|
this->is_updating_ = true;
|
||||||
|
|
||||||
|
if (exit_reparse) {
|
||||||
|
ESP_LOGD(TAG, "Exiting Nextion reparse mode");
|
||||||
|
if (!this->set_protocol_reparse_mode(false)) {
|
||||||
|
ESP_LOGW(TAG, "Failed to request Nextion to exit reparse mode");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Define the configuration for the HTTP client
|
// Define the configuration for the HTTP client
|
||||||
ESP_LOGV(TAG, "Establishing connection to HTTP server");
|
ESP_LOGV(TAG, "Establishing connection to HTTP server");
|
||||||
ESP_LOGVV(TAG, "Available heap: %" PRIu32, esp_get_free_heap_size());
|
ESP_LOGVV(TAG, "Available heap: %" PRIu32, esp_get_free_heap_size());
|
||||||
|
|
Loading…
Reference in a new issue