NTP Client for the "old" NetServices libraries

Dependents:   NTPClientExample server1 server2 RFID2Twitter ... more

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu Aug 05 15:16:59 2010 +0000
Parent:
3:1849420bb9a9
Commit message:

Changed in this revision

LPC1768/NTPClient.ar Show annotated file Show diff for this revision Revisions of this file
LPC1768/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/ntp/NTPClient.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/NTPClient.ar Show annotated file Show diff for this revision Revisions of this file
LPC2368/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/services/ntp/NTPClient.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1849420bb9a9 -r 7c3f1199256a LPC1768/NTPClient.ar
Binary file LPC1768/NTPClient.ar has changed
diff -r 1849420bb9a9 -r 7c3f1199256a LPC1768/dbg/dbg.h
--- a/LPC1768/dbg/dbg.h	Fri Jul 09 14:46:52 2010 +0000
+++ b/LPC1768/dbg/dbg.h	Thu Aug 05 15:16:59 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Debugging helpers header file
+*/
+
 //#ifdef DBG_H
 //#define DBG_H
 
@@ -28,6 +32,11 @@
 #define __DEBUG
 #endif
 
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
 #ifdef __DEBUG
 
 #ifndef __DEBUGSTREAM
@@ -47,8 +56,15 @@
 #undef DBG
 #undef DBG_END
 #undef BREAK
+
+///Debug output (if enabled), same syntax as printf, with heading info
 #define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
+
+///Debug output (if enabled), same syntax as printf, no heading info
+#define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
 #define DBG_END DebugStream::release
+
+///Break point usin serial debug interface (if debug enbaled)
 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
 #endif
 
diff -r 1849420bb9a9 -r 7c3f1199256a LPC1768/services/ntp/NTPClient.h
--- a/LPC1768/services/ntp/NTPClient.h	Fri Jul 09 14:46:52 2010 +0000
+++ b/LPC1768/services/ntp/NTPClient.h	Thu Aug 05 15:16:59 2010 +0000
@@ -21,32 +21,69 @@
 THE SOFTWARE.
 */
 
+/** \file
+NTP Client header file
+*/
+
 #ifndef NTP_CLIENT_H
 #define NTP_CLIENT_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/netservice.h"
 #include "api/UDPSocket.h"
 #include "api/DNSRequest.h"
 #include "mbed.h"
 
+///NTP Client results
 enum NTPResult
 {
-  NTP_OK,
-  NTP_PROCESSING,
-  NTP_PRTCL, //Protocol error
-  NTP_TIMEOUT, //Connection timeout
-  NTP_DNS //Could not resolve DNS Addr
+  NTP_OK, ///<Success
+  NTP_PROCESSING, ///<Processing
+  NTP_PRTCL, ///<Protocol error
+  NTP_TIMEOUT, ///<Connection timeout
+  NTP_DNS ///<Could not resolve DNS hostname
 };
 
+///A NTP Client
+/**
+The NTP client is a simple UDP client that will update the mbed's RTC
+*/
 class NTPClient : protected NetService
 {
 public:
+  /**
+  Instantiates the NTP client
+  */
   NTPClient();
   virtual ~NTPClient();
   
   //High level setup functions
+  
+  ///Gets current time (blocking)
+  /**
+  Updates the time using the server host
+  Blocks until completion
+  @param host : NTP server
+  */
   NTPResult setTime(const Host& host); //Blocking
+  
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time using the server host
+  The function returns immediately and calls the callback on completion or error
+  @param host : NTP server
+  @param pMethod : callback function
+  */
   NTPResult setTime(const Host& host, void (*pMethod)(NTPResult)); //Non blocking
+  
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time
+  @param host : NTP server
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  The function returns immediately and calls the callback on completion or error
+  */
   template<class T> 
   NTPResult setTime(const Host& host, T* pItem, void (T::*pMethod)(NTPResult)) //Non blocking
   {
@@ -55,9 +92,25 @@
     return NTP_PROCESSING;
   }
   
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time using the server host
+  The function returns immediately and calls the previously set callback on completion or error
+  @param host : NTP server
+  */
   void doSetTime(const Host& host);
   
+  ///Setups the result callback
+  /**
+  @param pMethod : callback function
+  */
   void setOnResult( void (*pMethod)(NTPResult) );
+  
+  ///Setups the result callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   class CDummy;
   template<class T> 
   void setOnResult( T* pItem, void (T::*pMethod)(NTPResult) )
diff -r 1849420bb9a9 -r 7c3f1199256a LPC2368/NTPClient.ar
Binary file LPC2368/NTPClient.ar has changed
diff -r 1849420bb9a9 -r 7c3f1199256a LPC2368/dbg/dbg.h
--- a/LPC2368/dbg/dbg.h	Fri Jul 09 14:46:52 2010 +0000
+++ b/LPC2368/dbg/dbg.h	Thu Aug 05 15:16:59 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Debugging helpers header file
+*/
+
 //#ifdef DBG_H
 //#define DBG_H
 
@@ -28,6 +32,11 @@
 #define __DEBUG
 #endif
 
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
 #ifdef __DEBUG
 
 #ifndef __DEBUGSTREAM
@@ -47,8 +56,15 @@
 #undef DBG
 #undef DBG_END
 #undef BREAK
+
+///Debug output (if enabled), same syntax as printf, with heading info
 #define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
+
+///Debug output (if enabled), same syntax as printf, no heading info
+#define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
 #define DBG_END DebugStream::release
+
+///Break point usin serial debug interface (if debug enbaled)
 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
 #endif
 
diff -r 1849420bb9a9 -r 7c3f1199256a LPC2368/services/ntp/NTPClient.h
--- a/LPC2368/services/ntp/NTPClient.h	Fri Jul 09 14:46:52 2010 +0000
+++ b/LPC2368/services/ntp/NTPClient.h	Thu Aug 05 15:16:59 2010 +0000
@@ -21,32 +21,69 @@
 THE SOFTWARE.
 */
 
+/** \file
+NTP Client header file
+*/
+
 #ifndef NTP_CLIENT_H
 #define NTP_CLIENT_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/netservice.h"
 #include "api/UDPSocket.h"
 #include "api/DNSRequest.h"
 #include "mbed.h"
 
+///NTP Client results
 enum NTPResult
 {
-  NTP_OK,
-  NTP_PROCESSING,
-  NTP_PRTCL, //Protocol error
-  NTP_TIMEOUT, //Connection timeout
-  NTP_DNS //Could not resolve DNS Addr
+  NTP_OK, ///<Success
+  NTP_PROCESSING, ///<Processing
+  NTP_PRTCL, ///<Protocol error
+  NTP_TIMEOUT, ///<Connection timeout
+  NTP_DNS ///<Could not resolve DNS hostname
 };
 
+///A NTP Client
+/**
+The NTP client is a simple UDP client that will update the mbed's RTC
+*/
 class NTPClient : protected NetService
 {
 public:
+  /**
+  Instantiates the NTP client
+  */
   NTPClient();
   virtual ~NTPClient();
   
   //High level setup functions
+  
+  ///Gets current time (blocking)
+  /**
+  Updates the time using the server host
+  Blocks until completion
+  @param host : NTP server
+  */
   NTPResult setTime(const Host& host); //Blocking
+  
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time using the server host
+  The function returns immediately and calls the callback on completion or error
+  @param host : NTP server
+  @param pMethod : callback function
+  */
   NTPResult setTime(const Host& host, void (*pMethod)(NTPResult)); //Non blocking
+  
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time
+  @param host : NTP server
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  The function returns immediately and calls the callback on completion or error
+  */
   template<class T> 
   NTPResult setTime(const Host& host, T* pItem, void (T::*pMethod)(NTPResult)) //Non blocking
   {
@@ -55,9 +92,25 @@
     return NTP_PROCESSING;
   }
   
+  ///Gets current time (non-blocking)
+  /**
+  Updates the time using the server host
+  The function returns immediately and calls the previously set callback on completion or error
+  @param host : NTP server
+  */
   void doSetTime(const Host& host);
   
+  ///Setups the result callback
+  /**
+  @param pMethod : callback function
+  */
   void setOnResult( void (*pMethod)(NTPResult) );
+  
+  ///Setups the result callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   class CDummy;
   template<class T> 
   void setOnResult( T* pItem, void (T::*pMethod)(NTPResult) )