SNTP Time wrong?!

Blackfarmer
Posts: 7
Joined: Tue May 19, 2015 3:43 am

SNTP Time wrong?!

Postby Blackfarmer » Tue May 19, 2015 3:55 am

Hello,

I used the new SDK API function to get a time via SNTP, but the time I received is wrong.

For example I received the time:
1432006860 (Mon May 18 21:41:00 2015)
but it should be
1431978060

The API describes only an offset for the sntp_get_real_time funtion, but not for the sntp_get_current_timestamp function.

So for me this is a bug in the sntp_get_current_timestamp function.

Also for me it is not necessary for the sntp_get_real_time function to add an fixed offset there. The offset should be a parameter or it can be done by adding the offset myself. It belongs to the user which time he wants to have.

Btw.
Great Chip with a great SDK!!! THANKS!

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: SNTP Time wrong?!

Postby ESP_Faye » Thu May 21, 2015 9:48 am

Hi,

Sorry for the inconvenience.

Description of sntp_get_current_timestamp is wrong, sntp default to be GMT+8 Time Zone now,we will add an API to set Time Zone.

Thanks for your interest in ESP8266 !

Blackfarmer
Posts: 7
Joined: Tue May 19, 2015 3:43 am

Re: SNTP Time wrong?!

Postby Blackfarmer » Fri May 29, 2015 1:58 am

Hi,

this sounds very good! I have an additional question:

it seems, that the function sntp_get_current_timestamp() receives the time from an internal clock. I don't see, that every call on this functions invokes a new NTP request over the network.

What is the period, which the time is refreshed over NTP? Is it possible to change this settings? It would make it more convenient to get access to this parameters.

When do you expect to release the updated SDK?

Best regards
Blackfarmer

Blackfarmer
Posts: 7
Joined: Tue May 19, 2015 3:43 am

Re: SNTP Time wrong?!

Postby Blackfarmer » Fri May 29, 2015 2:43 am

Hi again,

I think there is still a bug. Can you please check following behavior:

It's only a test snippet to get familiar with the SDK ;)

Code: Select all

void ICACHE_FLASH_ATTR periodFnct0(void)
{
   uint32_t sys_time = system_get_time();
   printf("Timer Function 0 (Time: %d us)\n", sys_time);
   
   if (wifi_station_get_connect_status() == STATION_GOT_IP)
   {
      uint32_t current_stamp = sntp_get_current_timestamp();
      if (current_stamp != 0)
         printf("sntp: %d, %s\n", current_stamp, sntp_get_real_time(current_stamp-21600));
   }
}


If the system timer overflows from positiv to negative number, the time gets wrong:

correct:
Timer Function 0 (Time: 2146985873 us)
sntp: 1432866382, Thu May 28 20:26:22 2015

wrong:
Timer Function 0 (Time: -2146981423 us)
sntp: 1432862090, Thu May 28 19:14:50 2015


Note that this is tested with SDK 1.0.1, I have some problems to compile with 1.1.0, but I'm on discovering this. Should be not topic here.

Best regards
Blackfarmer

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: SNTP Time wrong?!

Postby ESP_Faye » Tue Jun 16, 2015 2:43 pm

Hi,

Please have a try with the SDK_v1.1.2 http://bbs.espressif.com/viewforum.php?f=5

did your problem solved?

SpenZerX
Posts: 41
Joined: Thu Apr 16, 2015 9:30 pm
Location: Germany
Contact:

Re: SNTP Time wrong?!

Postby SpenZerX » Wed Jun 17, 2015 2:20 am

Hi Espressif,

where is sntp_get_timezone ?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: SNTP Time wrong?!

Postby ESP_Faye » Wed Jun 17, 2015 10:17 am

Hi,

Sorry that we don't have this API right now.

But we will add it in next SDK.

Thanks for your interest in ESP8266 !

Blackfarmer
Posts: 7
Joined: Tue May 19, 2015 3:43 am

Re: SNTP Time wrong?!

Postby Blackfarmer » Sat Jun 20, 2015 6:01 pm

Hi,

yes, in V1.1.2 this issue is fixed!

Thanks for it!

Best regards
Blackfarmer

Who is online

Users browsing this forum: No registered users and 102 guests