Skip to content

Commit 4af1312

Browse files
authored
Merge pull request #730 from gojimmypi/pr-release-timelib-fix
Adjust Espressif wolfssl_echoserver example timehelper
2 parents bbba8ae + fa23bf5 commit 4af1312

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/main.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
#include <esp_log.h>
2727

2828
/* wolfSSL */
29-
#include "user_settings.h" /* always include wolfSSL user_settings.h first */
29+
#include <wolfssl/wolfcrypt/settings.h> /* includes wolfSSL user-settings.h */
30+
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
31+
#ifndef WOLFSSL_ESPIDF
32+
#warning "Problem with wolfSSL user_settings."
33+
#warning "Check components/wolfssl/include"
34+
#endif
3035
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
3136
#include <wolfssl/version.h>
3237

ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/include/time_helper.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,23 @@
3030
extern "C" {
3131
#endif
3232

33+
#include <esp_err.h>
34+
3335
/* a function to show the current data and time */
34-
int esp_show_current_datetime();
36+
esp_err_t esp_show_current_datetime();
3537

3638
/* worst case, if GitHub time not available, used fixed time */
37-
int set_fixed_default_time(void);
39+
esp_err_t set_fixed_default_time(void);
3840

3941
/* set time from string (e.g. GitHub commit time) */
40-
int set_time_from_string(char* time_buffer);
42+
esp_err_t set_time_from_string(const char* time_buffer);
4143

4244
/* set time from NTP servers,
4345
* also initially calls set_fixed_default_time or set_time_from_string */
44-
int set_time(void);
46+
esp_err_t set_time(void);
4547

4648
/* wait NTP_RETRY_COUNT seconds before giving up on NTP time */
47-
int set_time_wait_for_ntp(void);
49+
esp_err_t set_time_wait_for_ntp(void);
4850

4951
#ifdef __cplusplus
5052
} /* extern "C" */

ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static const char* const TAG = "My Project";
4646
void app_main(void)
4747
{
4848
func_args args = {0};
49-
int ret = ESP_OK;
49+
esp_err_t ret = ESP_OK;
5050

5151
ESP_LOGI(TAG, "------------ wolfSSL wolfSSH template Example ----------");
5252
ESP_LOGI(TAG, "--------------------------------------------------------");

ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/time_helper.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST;
9191
extern char* ntpServerList[NTP_SERVER_COUNT];
9292

9393
/* Show the current date and time */
94-
int esp_show_current_datetime()
94+
esp_err_t esp_show_current_datetime()
9595
{
9696
time_t now;
9797
char strftime_buf[64];
@@ -108,7 +108,7 @@ int esp_show_current_datetime()
108108
}
109109

110110
/* the worst-case scenario is a hard-coded date/time */
111-
int set_fixed_default_time(void)
111+
esp_err_t set_fixed_default_time(void)
112112
{
113113
/* ideally, we'd like to set time from network,
114114
* but let's set a default time, just in case */
@@ -138,7 +138,7 @@ int set_fixed_default_time(void)
138138
*
139139
* returns 0 = success if able to set the time from the provided string
140140
* error for any other value, typically -1 */
141-
int set_time_from_string(char* time_buffer)
141+
esp_err_t set_time_from_string(const char* time_buffer)
142142
{
143143
/* expecting github default formatting: 'Thu Aug 31 12:41:45 2023 -0700' */
144144
const char *format = "%3s %3s %d %d:%d:%d %d %s";
@@ -222,7 +222,7 @@ int set_time_from_string(char* time_buffer)
222222
}
223223

224224
/* set time; returns 0 if succecssfully configured with NTP */
225-
int set_time(void)
225+
esp_err_t set_time(void)
226226
{
227227
#ifndef NTP_SERVER_COUNT
228228
ESP_LOGW(TAG, "Warning: no sntp server names defined. "
@@ -319,7 +319,7 @@ int set_time(void)
319319
}
320320

321321
/* wait for NTP to actually set the time */
322-
int set_time_wait_for_ntp(void)
322+
esp_err_t set_time_wait_for_ntp(void)
323323
{
324324
int ret = 0;
325325
#ifdef HAS_ESP_NETIF_SNTP

0 commit comments

Comments
 (0)