Adjust Espressif wolfssl_echoserver example timehelper

pull/730/head
gojimmypi 2024-07-22 20:57:03 -07:00
parent bbba8aef04
commit fa23bf58df
No known key found for this signature in database
GPG Key ID: 3D684FA88DC3FAA8
4 changed files with 19 additions and 12 deletions

View File

@ -26,7 +26,12 @@
#include <esp_log.h> #include <esp_log.h>
/* wolfSSL */ /* 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/wolfcrypt/port/Espressif/esp32-crypt.h>
#include <wolfssl/version.h> #include <wolfssl/version.h>

View File

@ -30,21 +30,23 @@
extern "C" { extern "C" {
#endif #endif
#include <esp_err.h>
/* a function to show the current data and time */ /* 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 */ /* 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) */ /* 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, /* set time from NTP servers,
* also initially calls set_fixed_default_time or set_time_from_string */ * 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 */ /* 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 #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -46,7 +46,7 @@ static const char* const TAG = "My Project";
void app_main(void) void app_main(void)
{ {
func_args args = {0}; func_args args = {0};
int ret = ESP_OK; esp_err_t ret = ESP_OK;
ESP_LOGI(TAG, "------------ wolfSSL wolfSSH template Example ----------"); ESP_LOGI(TAG, "------------ wolfSSL wolfSSH template Example ----------");
ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------");

View File

@ -91,7 +91,7 @@ char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST;
extern char* ntpServerList[NTP_SERVER_COUNT]; extern char* ntpServerList[NTP_SERVER_COUNT];
/* Show the current date and time */ /* Show the current date and time */
int esp_show_current_datetime() esp_err_t esp_show_current_datetime()
{ {
time_t now; time_t now;
char strftime_buf[64]; char strftime_buf[64];
@ -108,7 +108,7 @@ int esp_show_current_datetime()
} }
/* the worst-case scenario is a hard-coded date/time */ /* 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, /* ideally, we'd like to set time from network,
* but let's set a default time, just in case */ * 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 * returns 0 = success if able to set the time from the provided string
* error for any other value, typically -1 */ * 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' */ /* expecting github default formatting: 'Thu Aug 31 12:41:45 2023 -0700' */
const char *format = "%3s %3s %d %d:%d:%d %d %s"; 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 */ /* set time; returns 0 if succecssfully configured with NTP */
int set_time(void) esp_err_t set_time(void)
{ {
#ifndef NTP_SERVER_COUNT #ifndef NTP_SERVER_COUNT
ESP_LOGW(TAG, "Warning: no sntp server names defined. " 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 */ /* 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; int ret = 0;
#ifdef HAS_ESP_NETIF_SNTP #ifdef HAS_ESP_NETIF_SNTP