ESP8266 Developer Zone The Official ESP8266 Forum 2019-02-12T01:23:47+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=25772 2019-02-12T01:23:47+08:00 2019-02-12T01:23:47+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25772&p=37500#p37500 <![CDATA[Re: ESP8266_RTOS_SDK_v2.x.x => Problem using configTime and getting time]]>

Statistics: Posted by Guest — Tue Feb 12, 2019 1:23 am


]]>
2019-02-11T17:38:47+08:00 2019-02-11T17:38:47+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25772&p=37494#p37494 <![CDATA[Re: ESP8266_RTOS_SDK_v2.x.x => Problem using configTime and getting time]]>
#include "apps/sntp.h"
#include "apps/sntp_time.h"
#include "apps/time.h"

.
.
.
updateTime(60*60000);
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "pool.ntp.org");
sntp_set_timezone(user_timezone); // user defined (in my case user_timezone=1)
sntp_init();
while (sntp_get_current_timestamp() == 0) // this loop should be limited in case wifi is not available (otherwise it will get stuck in it)!
vTaskDelay(1000 / portTICK_RATE_MS);

After this initialization I usually see one-time message

"please start sntp first !"

and then it exits the loop with sntp properly initialized. From then each call to time(NULL) will return proper epoch time (adjusted for timezone).

Statistics: Posted by btomic — Mon Feb 11, 2019 5:38 pm


]]>
2019-02-01T15:05:43+08:00 2019-02-01T15:05:43+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25772&p=37177#p37177 <![CDATA[Re: ESP8266_RTOS_SDK_v2.x.x => Problem using configTime and getting time]]> In any case, I was actually able to find a piece of example for the v2.x.x here: https://github.com/espressif/ESP8266_RTOS_SDK/blob/release/v2.x.x/examples/wolfssl_demo/user/wolfssl_client.c

I guess I am still confused on why the APIs in time.c for that version are still implemented since they obviously don't seem to be working as one would be expecting.

Thanks for your help!

Statistics: Posted by Guest — Fri Feb 01, 2019 3:05 pm


]]>
2019-02-01T11:45:05+08:00 2019-02-01T11:45:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25772&p=37172#p37172 <![CDATA[Re: ESP8266_RTOS_SDK_v2.x.x => Problem using configTime and getting time]]> https://github.com/espressif/ESP8266_RT ... ocols/sntp

Statistics: Posted by Her Mary — Fri Feb 01, 2019 11:45 am


]]>
2019-02-01T07:25:17+08:00 2019-02-01T07:25:17+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25772&p=37164#p37164 <![CDATA[ESP8266_RTOS_SDK_v2.x.x => Problem using configTime and getting time]]>
I am using the ESP8266_RTOS_SDK_v2.x.x with my ESP8266. I need to connect to my Cloud (using Google Cloud Platform) and to do this, I generate a JWT. For that, I need the Unix time so I can set the validity of the token I am creating.
So, I am trying to use the API

Code:

configTime
for that. I call it like that:

Code:

   
   ret_bool = configTime(1, 1, "pool.ntp.org", NULL, NULL, true);
    ESP_LOG_INFO("ret_bool after: %d", ret_bool);
    time_t now = time(NULL);


The problem is that, even though ret_bool is returning 1 (everything went well calling

Code:

configTime
), it doesn't work (time(NULL) = a random int that is wrong) and I get the message

please start sntp first !
everytime.

I can't figure out what is going wrong, as I am using the time.h API provided in the ESP8266_RTOS_SDK_v2.x.x

Does anyone have an idea of what I could be doing wrong?

PS: I do establish a WiFI internet connection prior to calling

Code:

configTime


Thanks

Statistics: Posted by Guest — Fri Feb 01, 2019 7:25 am


]]>