From fa23bf58dff609722064f2cd6b7b441066940bb6 Mon Sep 17 00:00:00 2001 From: gojimmypi Date: Mon, 22 Jul 2024 20:57:03 -0700 Subject: [PATCH] Adjust Espressif wolfssl_echoserver example timehelper --- .../examples/wolfssh_echoserver/main/include/main.h | 7 ++++++- .../wolfssh_echoserver/main/include/time_helper.h | 12 +++++++----- .../ESP-IDF/examples/wolfssh_echoserver/main/main.c | 2 +- .../examples/wolfssh_echoserver/main/time_helper.c | 10 +++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/main.h b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/main.h index 73d227693..9aa80070c 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/main.h +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/main.h @@ -26,7 +26,12 @@ #include /* wolfSSL */ -#include "user_settings.h" /* always include wolfSSL user_settings.h first */ +#include /* includes wolfSSL user-settings.h */ +#include +#ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" +#endif #include #include diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/time_helper.h b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/time_helper.h index e244ddd17..e7b8108d2 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/time_helper.h +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/time_helper.h @@ -30,21 +30,23 @@ extern "C" { #endif +#include + /* a function to show the current data and time */ -int esp_show_current_datetime(); +esp_err_t esp_show_current_datetime(); /* worst case, if GitHub time not available, used fixed time */ -int set_fixed_default_time(void); +esp_err_t set_fixed_default_time(void); /* set time from string (e.g. GitHub commit time) */ -int set_time_from_string(char* time_buffer); +esp_err_t set_time_from_string(const char* time_buffer); /* set time from NTP servers, * also initially calls set_fixed_default_time or set_time_from_string */ -int set_time(void); +esp_err_t set_time(void); /* wait NTP_RETRY_COUNT seconds before giving up on NTP time */ -int set_time_wait_for_ntp(void); +esp_err_t set_time_wait_for_ntp(void); #ifdef __cplusplus } /* extern "C" */ diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/main.c b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/main.c index b1c9835a7..8a0db6f0a 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/main.c +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/main.c @@ -46,7 +46,7 @@ static const char* const TAG = "My Project"; void app_main(void) { func_args args = {0}; - int ret = ESP_OK; + esp_err_t ret = ESP_OK; ESP_LOGI(TAG, "------------ wolfSSL wolfSSH template Example ----------"); ESP_LOGI(TAG, "--------------------------------------------------------"); diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/time_helper.c b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/time_helper.c index 498c53d78..09174d7c8 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/time_helper.c +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/time_helper.c @@ -91,7 +91,7 @@ char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST; extern char* ntpServerList[NTP_SERVER_COUNT]; /* Show the current date and time */ -int esp_show_current_datetime() +esp_err_t esp_show_current_datetime() { time_t now; char strftime_buf[64]; @@ -108,7 +108,7 @@ int esp_show_current_datetime() } /* the worst-case scenario is a hard-coded date/time */ -int set_fixed_default_time(void) +esp_err_t set_fixed_default_time(void) { /* ideally, we'd like to set time from network, * but let's set a default time, just in case */ @@ -138,7 +138,7 @@ int set_fixed_default_time(void) * * returns 0 = success if able to set the time from the provided string * error for any other value, typically -1 */ -int set_time_from_string(char* time_buffer) +esp_err_t set_time_from_string(const char* time_buffer) { /* expecting github default formatting: 'Thu Aug 31 12:41:45 2023 -0700' */ const char *format = "%3s %3s %d %d:%d:%d %d %s"; @@ -222,7 +222,7 @@ int set_time_from_string(char* time_buffer) } /* set time; returns 0 if succecssfully configured with NTP */ -int set_time(void) +esp_err_t set_time(void) { #ifndef NTP_SERVER_COUNT ESP_LOGW(TAG, "Warning: no sntp server names defined. " @@ -319,7 +319,7 @@ int set_time(void) } /* wait for NTP to actually set the time */ -int set_time_wait_for_ntp(void) +esp_err_t set_time_wait_for_ntp(void) { int ret = 0; #ifdef HAS_ESP_NETIF_SNTP