EthernetNetIf Compatibility.
Dependents: XBeeWiFi_SPI_example
Fork of NetServicesSource by
Diff: services/ntp/NTPClient.h
- Revision:
- 5:dd63a1e02b1b
- Parent:
- 2:a4f97773c90f
- Child:
- 6:b7dd7cde8ad2
--- a/services/ntp/NTPClient.h Fri Jul 09 14:46:47 2010 +0000 +++ b/services/ntp/NTPClient.h Tue Jul 27 15:59:42 2010 +0000 @@ -29,24 +29,56 @@ #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_PRTCL, ///Protocol error + NTP_TIMEOUT, ///Connection timeout + NTP_DNS ///Could not resolve DNS Addr }; +///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 +87,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) )