mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 17:16:29 +08:00
feat/wolfssl_http_client: Added wolfssl support to http-client & ota.
Changes: Client, OTA examples fixed. Bug fixes in esp-tls wolfssl support.
This commit is contained in:
@ -18,6 +18,10 @@
|
||||
|
||||
#include "esp_http_client.h"
|
||||
|
||||
#if CONFIG_SSL_USING_WOLFSSL
|
||||
#include "lwip/apps/sntp.h"
|
||||
#endif
|
||||
|
||||
#define MAX_HTTP_RECV_BUFFER 512
|
||||
static const char *TAG = "HTTP_CLIENT";
|
||||
|
||||
@ -67,6 +71,40 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_SSL_USING_WOLFSSL
|
||||
static void get_time()
|
||||
{
|
||||
struct timeval now;
|
||||
int sntp_retry_cnt = 0;
|
||||
int sntp_retry_time = 0;
|
||||
|
||||
sntp_setoperatingmode(0);
|
||||
sntp_setservername(0, "pool.ntp.org");
|
||||
sntp_init();
|
||||
|
||||
while (1) {
|
||||
for (int32_t i = 0; (i < (SNTP_RECV_TIMEOUT / 100)) && now.tv_sec < 1525952900; i++) {
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gettimeofday(&now, NULL);
|
||||
}
|
||||
|
||||
if (now.tv_sec < 1525952900) {
|
||||
sntp_retry_time = SNTP_RECV_TIMEOUT << sntp_retry_cnt;
|
||||
|
||||
if (SNTP_RECV_TIMEOUT << (sntp_retry_cnt + 1) < SNTP_RETRY_TIMEOUT_MAX) {
|
||||
sntp_retry_cnt ++;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG,"SNTP get time failed, retry after %d ms\n", sntp_retry_time);
|
||||
vTaskDelay(sntp_retry_time / portTICK_RATE_MS);
|
||||
} else {
|
||||
ESP_LOGI(TAG,"SNTP get time success\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void http_rest()
|
||||
{
|
||||
esp_http_client_config_t config = {
|
||||
@ -375,6 +413,11 @@ static void https_async()
|
||||
|
||||
static void http_test_task(void *pvParameters)
|
||||
{
|
||||
#if CONFIG_SSL_USING_WOLFSSL
|
||||
/* CA date verification need system time */
|
||||
get_time();
|
||||
#endif
|
||||
|
||||
app_wifi_wait_connected();
|
||||
ESP_LOGI(TAG, "Connected to AP, begin http example");
|
||||
http_rest();
|
||||
|
Reference in New Issue
Block a user