Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Espressif wolfssl_echoserver example timehelper #730

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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>

Original file line number Diff line number Diff line change
@@ -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" */
Original file line number Diff line number Diff line change
@@ -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, "--------------------------------------------------------");
Original file line number Diff line number Diff line change
@@ -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