Compare commits
2 Commits
88cf4af2a7
...
58132cb189
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58132cb189 | ||
|
|
e96329f976 |
@@ -21,7 +21,7 @@ external_components:
|
||||
- source: github://pr#3256 # adds esp-idf support to http_request
|
||||
components:
|
||||
- http_request
|
||||
- source: github://pr#5484 # adds exit reparse to Nextion library
|
||||
- source: github://pr#5484 #5660 # adds exit reparse to Nextion library
|
||||
components:
|
||||
- nextion
|
||||
|
||||
@@ -69,7 +69,20 @@ api:
|
||||
state: false
|
||||
- lambda: 'id(upload_tft).execute(url.c_str());'
|
||||
|
||||
#display:
|
||||
# - id: !extend disp1
|
||||
# tft_url: ${nextion_update_url}
|
||||
|
||||
script:
|
||||
- id: upload_tft_new
|
||||
mode: single
|
||||
parameters:
|
||||
url: string
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.upload_tft";
|
||||
ESP_LOGD(TAG, "Starting...");
|
||||
|
||||
- id: upload_tft
|
||||
mode: single
|
||||
parameters:
|
||||
@@ -443,21 +456,21 @@ script:
|
||||
auto upload_range_esp_idf_ = [&](const std::string &url, int range_start) -> int {
|
||||
static const char *const TAG = "script.upload_tft.upload_range_esp_idf_";
|
||||
ESP_LOGVV(TAG, "url: %s", url.c_str());
|
||||
ESP_LOGVV(TAG, "range_start: %i", range_start);
|
||||
uint range_size_ = tft_size_ - range_start;
|
||||
ESP_LOGVV(TAG, "range_size_: %i", range_size_);
|
||||
if (range_size_ <= 0) {
|
||||
ESP_LOGE(TAG, "Invalid range");
|
||||
return -1;
|
||||
}
|
||||
ESP_LOGVV(TAG, "tft_size_: %i", tft_size_);
|
||||
ESP_LOGV(TAG, "Available heap: %u", esp_get_free_heap_size());
|
||||
|
||||
int range_end = (range_start == 0) ? std::min(tft_size_, 16383) : tft_size_;
|
||||
ESP_LOGVV(TAG, "range_end: %i", range_end);
|
||||
if (range_size_ <= 0 or range_end <= range_start) {
|
||||
ESP_LOGE(TAG, "Invalid range");
|
||||
ESP_LOGD(TAG, "Range start: %i", range_start);
|
||||
ESP_LOGD(TAG, "Range end: %i", range_end);
|
||||
ESP_LOGD(TAG, "Range size: %i", range_size_);
|
||||
return -1;
|
||||
}
|
||||
|
||||
esp_http_client_config_t config = {
|
||||
.url = url.c_str(),
|
||||
.cert_pem = nullptr,
|
||||
};
|
||||
esp_http_client_handle_t client = esp_http_client_init(&config);
|
||||
|
||||
@@ -473,9 +486,16 @@ script:
|
||||
esp_http_client_cleanup(client);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "Fetch content length");
|
||||
int content_length = esp_http_client_fetch_headers(client);
|
||||
ESP_LOGV(TAG, "content_length = %d", content_length);
|
||||
if (content_length <= 0) {
|
||||
ESP_LOGE(TAG, "Failed to get content length: %d", content_length);
|
||||
esp_http_client_cleanup(client);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int total_read_len = 0, read_len;
|
||||
|
||||
ESP_LOGV(TAG, "Allocate buffer");
|
||||
@@ -565,6 +585,7 @@ script:
|
||||
ESP_LOGVV(TAG, "Available heap: %u", esp_get_free_heap_size());
|
||||
esp_http_client_config_t config = {
|
||||
.url = url.c_str(),
|
||||
.cert_pem = nullptr,
|
||||
.method = HTTP_METHOD_HEAD,
|
||||
.timeout_ms = 15000,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user