NTP client to get UTC time from the internet time servers

Dependents:   NTPClient_HelloWorld

Fork of NTPClient by ST Expansion SW Team

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Mon Jan 02 15:44:40 2017 +0000
Parent:
5:fe36718063a5
Child:
7:2ac816b0f4ab
Commit message:
Set socket timeout

Changed in this revision

NTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
NTPClient.h Show annotated file Show diff for this revision Revisions of this file
--- a/NTPClient.cpp	Wed Dec 14 16:23:38 2016 +0000
+++ b/NTPClient.cpp	Mon Jan 02 15:44:40 2017 +0000
@@ -107,7 +107,7 @@
    
   //Create & bind socket
   if (m_sock.open(&m_intf) < 0) printf ("ERROR sock open \n\r");  
-  m_sock.set_blocking(true); //Set blocking  LICIO
+  m_sock.set_timeout(timeout);  
 
   struct NTPPacket pkt;  
   memset (&pkt, 0, sizeof(NTPPacket));   
--- a/NTPClient.h	Wed Dec 14 16:23:38 2016 +0000
+++ b/NTPClient.h	Mon Jan 02 15:44:40 2017 +0000
@@ -64,7 +64,7 @@
   @param timeout waiting timeout in ms (osWaitForever for blocking function, not recommended)
   @return 0 on success, NTP error code (<0) on failure
   */
-  NTPResult setTime(const char* host, uint16_t port = NTP_DEFAULT_PORT, uint32_t timeout = NTP_DEFAULT_TIMEOUT); //Blocking
+  NTPResult setTime(const char* host, uint16_t port = NTP_DEFAULT_PORT, uint32_t timeout = NTP_DEFAULT_TIMEOUT); 
 
 private:
   struct NTPPacket //See RFC 4330 for Simple NTP