Skip to content

Commit

Permalink
Merge pull request wolfSSL#730 from gojimmypi/pr-release-timelib-fix
Browse files Browse the repository at this point in the history
Adjust Espressif wolfssl_echoserver example timehelper
  • Loading branch information
ejohnstown authored Jul 23, 2024
2 parents bbba8ae + fa23bf5 commit 4af1312
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
#include <esp_log.h>

/* wolfSSL */
#include "user_settings.h" /* always include wolfSSL user_settings.h first */
#include <wolfssl/wolfcrypt/settings.h> /* includes wolfSSL user-settings.h */
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
#ifndef WOLFSSL_ESPIDF
#warning "Problem with wolfSSL user_settings."
#warning "Check components/wolfssl/include"
#endif
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
#include <wolfssl/version.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@
extern "C" {
#endif

#include <esp_err.h>

/* 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" */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "--------------------------------------------------------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 */
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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. "
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4af1312

Please sign in to comment.