NTP server giving time after long time

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

NTP server giving time after long time

Postby burkulesomesh43 » Fri Jan 11, 2019 11:43 am

Hi all,
I have used sntp example from esp idf and modified it as per my use as folllows-->>>

Code: Select all

void sntp_task(void *pvParameter) {

	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	sntp_setservername(0,"asia.pool.ntp.org");
	sntp_init();

	time_t now;
	struct tm timeinfo;
	struct tm *tmp;
	time(&now);
	localtime_r(&now, &timeinfo);
	while(timeinfo.tm_year < (2019 - 1900))
	{   
		printf("Time not set, trying...\n");
		vTaskDelay(5000 / portTICK_PERIOD_MS);
		time(&now);
                localtime_r(&now, &timeinfo);
      }

	while(1)
	{
		
		time(&now);
		setenv("TZ", "UTC-5:30", 1);
		tzset();
		tmp = localtime( &now );
		strftime(Timebuffer, sizeof(Timebuffer), "%d/%m/%Y  %I:%M:%S %p", tmp);
	
		vTaskDelay(999 / portTICK_RATE_MS);
	}
}
but sometimes it does not gives time instantly or can't get time.
Don't know what is the problem.
please help me out to solve this.
--
Somesh Burkule

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: NTP server giving time after long time

Postby Ritesh » Fri Jan 11, 2019 5:04 pm

Hi,

We have used ntp into our project but we have applied all server which are used for ntp server configuration. So, We haven't faced any issue like that.

Would you please try with that as provided into sntp example and check with that?

It might be like sometime you will not get time from server and you will get it from second server as quickly as possible.
Regards,
Ritesh Prajapati

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

Re: NTP server giving time after long time

Postby burkulesomesh43 » Fri Jan 11, 2019 5:34 pm

Ritesh wrote:
Fri Jan 11, 2019 5:04 pm
Hi,

We have used ntp into our project but we have applied all server which are used for ntp server configuration. So, We haven't faced any issue like that.

Would you please try with that as provided into sntp example and check with that?

It might be like sometime you will not get time from server and you will get it from second server as quickly as possible.
can you please provide example you have used?
how can we use two servers?
--
Somesh Burkule

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: NTP server giving time after long time

Postby Ritesh » Sat Jan 12, 2019 10:55 am

burkulesomesh43 wrote:
Fri Jan 11, 2019 5:34 pm
Ritesh wrote:
Fri Jan 11, 2019 5:04 pm
Hi,

We have used ntp into our project but we have applied all server which are used for ntp server configuration. So, We haven't faced any issue like that.

Would you please try with that as provided into sntp example and check with that?

It might be like sometime you will not get time from server and you will get it from second server as quickly as possible.
can you please provide example you have used?
how can we use two servers?
Hi,

Please find attached code for reference purpose for SNTP Init Process.

Code: Select all

void initialize_sntp (void)
{
	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	sntp_setservername(0, "pool.ntp.org");
	sntp_setservername(1, "europe.pool.ntp.org");
	sntp_setservername(2, "uk.pool.ntp.org ");
	sntp_setservername(3, "us.pool.ntp.org");
	sntp_setservername(4, "time1.google.com");
	sntp_init();
}
Let me know if still issue after using that.
Regards,
Ritesh Prajapati

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

Re: NTP server giving time after long time

Postby burkulesomesh43 » Sat Jan 12, 2019 12:22 pm

Ritesh wrote:
Sat Jan 12, 2019 10:55 am
burkulesomesh43 wrote:
Fri Jan 11, 2019 5:34 pm
Ritesh wrote:
Fri Jan 11, 2019 5:04 pm
Hi,

We have used ntp into our project but we have applied all server which are used for ntp server configuration. So, We haven't faced any issue like that.

Would you please try with that as provided into sntp example and check with that?

It might be like sometime you will not get time from server and you will get it from second server as quickly as possible.
can you please provide example you have used?
how can we use two servers?
Hi,

Please find attached code for reference purpose for SNTP Init Process.

Code: Select all

void initialize_sntp (void)
{
	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	sntp_setservername(0, "pool.ntp.org");
	sntp_setservername(1, "europe.pool.ntp.org");
	sntp_setservername(2, "uk.pool.ntp.org ");
	sntp_setservername(3, "us.pool.ntp.org");
	sntp_setservername(4, "time1.google.com");
	sntp_init();
}
Let me know if still issue after using that.
I am getting this issue again.
Actually it gives that issue sometimes only but don't know, why?
--
Somesh Burkule

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: NTP server giving time after long time

Postby Ritesh » Sat Jan 12, 2019 1:05 pm

burkulesomesh43 wrote:
Sat Jan 12, 2019 12:22 pm
Ritesh wrote:
Sat Jan 12, 2019 10:55 am
burkulesomesh43 wrote:
Fri Jan 11, 2019 5:34 pm


can you please provide example you have used?
how can we use two servers?
Hi,

Please find attached code for reference purpose for SNTP Init Process.

Code: Select all

void initialize_sntp (void)
{
	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	sntp_setservername(0, "pool.ntp.org");
	sntp_setservername(1, "europe.pool.ntp.org");
	sntp_setservername(2, "uk.pool.ntp.org ");
	sntp_setservername(3, "us.pool.ntp.org");
	sntp_setservername(4, "time1.google.com");
	sntp_init();
}
Let me know if still issue after using that.
I am getting this issue again.
Actually it gives that issue sometimes only but don't know, why?
Please send me logs in details because we are using that way and didn't face any issue yet.
Regards,
Ritesh Prajapati

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

Re: NTP server giving time after long time

Postby burkulesomesh43 » Tue Jun 11, 2019 10:38 am

Ritesh wrote:
Sat Jan 12, 2019 1:05 pm
burkulesomesh43 wrote:
Sat Jan 12, 2019 12:22 pm
Ritesh wrote:
Sat Jan 12, 2019 10:55 am


Hi,

Please find attached code for reference purpose for SNTP Init Process.

Code: Select all

void initialize_sntp (void)
{
	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	sntp_setservername(0, "pool.ntp.org");
	sntp_setservername(1, "europe.pool.ntp.org");
	sntp_setservername(2, "uk.pool.ntp.org ");
	sntp_setservername(3, "us.pool.ntp.org");
	sntp_setservername(4, "time1.google.com");
	sntp_init();
}
Let me know if still issue after using that.
I am getting this issue again.
Actually it gives that issue sometimes only but don't know, why?
Please send me logs in details because we are using that way and didn't face any issue yet.
There is no logs generated. it only tries to reach NTP server continuosly.
--
Somesh Burkule

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: NTP server giving time after long time

Postby Ritesh » Tue Jun 11, 2019 10:55 am

burkulesomesh43 wrote:
Tue Jun 11, 2019 10:38 am
Ritesh wrote:
Sat Jan 12, 2019 1:05 pm
burkulesomesh43 wrote:
Sat Jan 12, 2019 12:22 pm

I am getting this issue again.
Actually it gives that issue sometimes only but don't know, why?
Please send me logs in details because we are using that way and didn't face any issue yet.
There is no logs generated. it only tries to reach NTP server continuosly.
Hi,

We have tried same way at our end and didn't face any issue till now. I just want to clarify that are you sending NTP request after getting proper IP and external connectivity into device itself?
Regards,
Ritesh Prajapati

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

Re: NTP server giving time after long time

Postby burkulesomesh43 » Tue Jun 11, 2019 10:59 am

Ritesh wrote:
Tue Jun 11, 2019 10:55 am
burkulesomesh43 wrote:
Tue Jun 11, 2019 10:38 am
Ritesh wrote:
Sat Jan 12, 2019 1:05 pm


Please send me logs in details because we are using that way and didn't face any issue yet.
There is no logs generated. it only tries to reach NTP server continuosly.
Hi,

We have tried same way at our end and didn't face any issue till now. I just want to clarify that are you sending NTP request after getting proper IP and external connectivity into device itself?
Yes, I am sending NTP request after connecting the device to Network.
--
Somesh Burkule

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: NTP server giving time after long time

Postby Ritesh » Tue Jun 11, 2019 11:10 am

burkulesomesh43 wrote:
Tue Jun 11, 2019 10:59 am
Ritesh wrote:
Tue Jun 11, 2019 10:55 am
burkulesomesh43 wrote:
Tue Jun 11, 2019 10:38 am

There is no logs generated. it only tries to reach NTP server continuosly.
Hi,

We have tried same way at our end and didn't face any issue till now. I just want to clarify that are you sending NTP request after getting proper IP and external connectivity into device itself?
Yes, I am sending NTP request after connecting the device to Network.
Then it should be worked?

Would you please try with master IDF as well with just sample STA example in which after getting IP event just ping to SNTP Server accordingly.

If still it is not working then there might be chances into your network as well or try with Hot-Spot as well with external network connectivity.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 442 guests