Merge branch 'master' into feature/esp32s2beta_update

This commit is contained in:
Angus Gratton
2019-08-08 13:44:24 +10:00
committed by Angus Gratton
2414 changed files with 160785 additions and 45781 deletions
@@ -45,8 +45,9 @@ def test_examples_protocol_esp_http_client(env, extra_data):
dut1.expect(re.compile(r"HTTP Absolute path redirect Status = 200, content_length = (\d)"))
dut1.expect(re.compile(r"HTTPS Status = 200, content_length = (\d)"))
dut1.expect(re.compile(r"HTTP redirect to HTTPS Status = 200, content_length = (\d)"), timeout=10)
dut1.expect(re.compile(r"HTTP chunk encoding Status = 200, content_length = -1"))
dut1.expect(re.compile(r"HTTP chunk encoding Status = 200, content_length = (\d)"))
dut1.expect(re.compile(r"HTTP Stream reader Status = 200, content_length = (\d)"))
dut1.expect(re.compile(r"Last esp error code: 0x8001"))
dut1.expect("Finish http example")
@@ -1,10 +1,6 @@
set(COMPONENT_SRCS "esp_http_client_example.c")
set(COMPONENT_ADD_INCLUDEDIRS ".")
# Embed the server root certificate into the final binary
#
# (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.)
set(COMPONENT_EMBED_TXTFILES howsmyssl_com_root_cert.pem)
register_component()
idf_component_register(SRCS "esp_http_client_example.c"
INCLUDE_DIRS "."
EMBED_TXTFILES howsmyssl_com_root_cert.pem)
@@ -17,6 +17,7 @@
#include "esp_event.h"
#include "tcpip_adapter.h"
#include "protocol_examples_common.h"
#include "esp_tls.h"
#include "esp_http_client.h"
@@ -63,7 +64,13 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
ESP_LOGD(TAG, "HTTP_EVENT_ON_FINISH");
break;
case HTTP_EVENT_DISCONNECTED:
ESP_LOGD(TAG, "HTTP_EVENT_DISCONNECTED");
ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED");
int mbedtls_err = 0;
esp_err_t err = esp_tls_get_and_clear_last_error(evt->data, &mbedtls_err, NULL);
if (err != 0) {
ESP_LOGI(TAG, "Last esp error code: 0x%x", err);
ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err);
}
break;
}
return ESP_OK;
@@ -485,6 +492,25 @@ static void https_async()
esp_http_client_cleanup(client);
}
static void https_with_invalid_url()
{
esp_http_client_config_t config = {
.url = "https://not.existent.url",
.event_handler = _http_event_handler,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
}
esp_http_client_cleanup(client);
}
static void http_test_task(void *pvParameters)
{
@@ -501,6 +527,7 @@ static void http_test_task(void *pvParameters)
http_download_chunk();
http_perform_as_stream_reader();
https_async();
https_with_invalid_url();
ESP_LOGI(TAG, "Finish http example");
vTaskDelete(NULL);
@@ -522,6 +549,7 @@ void app_main()
* examples/protocols/README.md for more information about this function.
*/
ESP_ERROR_CHECK(example_connect());
ESP_LOGI(TAG, "Connected to AP, begin http example");
xTaskCreate(&http_test_task, "http_test_task", 8192, NULL, 5, NULL);
}