mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
http_client: disconnect event to read last occurred error in esp-tls
This commit is contained in:
parent
587739391c
commit
a001eb39bf
@ -1145,7 +1145,7 @@ int esp_http_client_write(esp_http_client_handle_t client, const char *buffer, i
|
||||
esp_err_t esp_http_client_close(esp_http_client_handle_t client)
|
||||
{
|
||||
if (client->state >= HTTP_STATE_INIT) {
|
||||
http_dispatch_event(client, HTTP_EVENT_DISCONNECTED, NULL, 0);
|
||||
http_dispatch_event(client, HTTP_EVENT_DISCONNECTED, esp_transport_get_error_handle(client->transport), 0);
|
||||
client->state = HTTP_STATE_INIT;
|
||||
return esp_transport_close(client->transport);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user