Get Date-Time from internet NTP Server

Hiya,

Oops, sorry. I’m using firmware R7.4 on a Q2686…works fine for me.

ciao, Dave

Dear Sefer,

I am trying to connect with info.cyf-kr.edu.pl NTP server through UDP to get time stamp, but once i connect to the server i didnot get any reply, Please help me, do i need to send any command to server to get time stamp.

at+wipcfg=1
< OK
at+wipbr=1,6
< OK
at+wipbr=2,6,11,“internet”
< OK
at+wipbr=4,6,0
< OK
at+wipcreate=1,1,80,“info.cyf-kr.edu.pl”,123
< OK
<+WIPREADY 1,1

at+wipdata=1,1,1

CONNECT

Of course you do :exclamation:

That’s the way Client-Server systems work - the Client makes requests to the Server, and the Server responds to those requests.

Time to read-up on NTP: en.wikipedia.org/wiki/Network_Time_Protocol

and search this forum for further references…

Thanx for link…

But once the modem connected to UDP server, its goes to Data mode, so how can i send command…

Please help me with any specific command to get Time samp from the NTP server.

Pls…Pls…its urgent…

Pardon?

Your application must build a suitable UDP frame - in accordance with the NTP protocol - and send it!
And, of course, handle the UDP response!

Have you read the UDP specs?

Have you searched for previous posts?

Have you tried codesearch.google.com or similar to find existing open-source solutions?

In fact, did you look at the very first post (by sefer; 18 Apr 2007, 09:43) in this very thread :question:

Ah, sorry - I see you’re using the WIPSoft AT Commands.

In that case, you need to read the WIP AT Commands Manual to see how to supply a UDP frame to the modem once it has connected…

But i am new to NTP and UDP, and donot know how to use it, even i didnot get anything in WIPSOFT manual refgarding UDP handleing.

Please help me its urgent…

using wip-soft the best thing u can do now is
to make a desktop app which sends data to serial port then
to modem , which is connected to the server and will send your NTP
request and when i receives the response will send it to serial then to your
app which will parse the answer seeking for what you need ,
if you want the date/time of modem to be set according to a time server ,
WIPSOFT is not the answer , please look into wip samples so you
can make your own dwl.

This used to work intermitantly for me. Now it has stopped altogether.
My wip_UDPCreateOpts() returns a none NULL value i.e. no error, but the first event returned is WIP_CEV_ERROR
gsUDPSocket = wip_UDPCreateOpts((wip_eventHandler_f) UDPHandler, NULL, WIP_COPT_PEER_STRADDR, “1.uk.pool.ntp.org”, WIP_COPT_PEER_PORT, 123, WIP_COPT_END);

e.g.
Trace 1 [WIP] new UDP 0x180d71cc
Trace 1 GetNetTime() wip_UDPCreateOpts() opened
Trace 1 1.uk.pool.ntp.org
Trace 1 ERRLOG ch_channel.c:531: returned WIP_CERR_NOT_SUPPORTED
Trace 1 ERRLOG ch_udp.c:239: returned res
Trace 1 UDPHandler() WIP_CEV_ERROR 0
Trace 1 [WIP] closing UDP 0x180d71cc

I’ve tried a few different NTP addresses with no success. However if I enter numerical IP addresses of the NTP servers it works everytime. So its the DNS service that is failing.
Entering the IP address defeats the object of the pool DNS. Any DNS hints anyone?
: viewtopic.php?f=11&t=2646&p=9707#p9702
THeron states that DNS doesn’t work in older UDP. Is this still the case?

ntp servers you see in
pool.ntp.org/

pool.ntp.org

Is that a statement or question?

Hi,
I’ve copy-pasted the code and only get Time and not Date.

Can anybody help me?

What code?

The code form first message of this threat.

Sefer, thanks so much for sharing the code.

A small comment: NTPHeader is declared 47 bytes long:

ascii NTPHeader [47];

yet wip_write sends 48 bytes:

wip_write(udp_socket, NTPHeader, 48);

Obviously this works, but perhaps it would be safer (and saner) to have NTPHeader be declared one byte longer :slight_smile:

Better still, Don’t Use Magic Numbers :exclamation:

Hello,
I have tried your sample and it works.
Thanks :smiley:

ps How can I close the UDP socket opened for NTP?