AmrRT

Dependents:   LPC1768_AppBoard_Internet_LCD_Clock

Fork of EthernetNetIf by Donatien Garnier

Revision:
5:bc7df6da7589
Parent:
0:422060928e37
--- a/LPC2368/api/UDPSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/api/UDPSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,47 +21,86 @@
 THE SOFTWARE.
 */
 
+/** \file
+UDP Socket header file
+*/
+
 #ifndef UDPSOCKET_H
 #define UDPSOCKET_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetUdpSocket
 
+///UDP Socket error codes
 enum UDPSocketErr
 {
   __UDPSOCKET_MIN = -0xFFFF,
-  UDPSOCKET_SETUP, //NetUdpSocket not properly configured
-  UDPSOCKET_IF, //If has problems, does not exist or is not initialized
-  UDPSOCKET_MEM, //Not enough mem
-  UDPSOCKET_INUSE, //If/Port is in use
+  UDPSOCKET_SETUP, ///<UDPSocket not properly configured
+  UDPSOCKET_IF, ///<Interface has problems, does not exist or is not initialized
+  UDPSOCKET_MEM, ///<Not enough mem
+  UDPSOCKET_INUSE, ///<Interface / Port is in use
 //...
-  UDPSOCKET_OK = 0
+  UDPSOCKET_OK = 0 ///<Success
 };
 
-enum UDPSocketEvent //Only one lonely event here... but who knows, maybe some day there'll be another one!
+///UDP Socket Event(s)
+enum UDPSocketEvent //Only one event here for now, but keeps that model in case we need to implement some others
 {
-  UDPSOCKET_READABLE, //Data in buf
+  UDPSOCKET_READABLE, ///<Data in buf
 };
 
+class NetUdpSocket;
+enum NetUdpSocketEvent;
 
+///This is a simple UDP Socket class
+/**
+  This class exposes an API to deal with UDP Sockets
+*/
 class UDPSocket
 {
 public:
+  ///Creates a new socket
   UDPSocket();
+  
+  ///Closes and destroys socket
   ~UDPSocket(); //close()
   
+  ///Binds the socket to local host or a multicast address
   UDPSocketErr bind(const Host& me);
   
+  ///Sends data
+  /*
+  @param pHost : host to send data to
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : UDPSocketErr*/ sendto(const char* buf, int len, Host* pHost);
+  
+  ///Receives data
+  /*
+  @param pHost : host from which this piece of data comes from
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : UDPSocketErr*/ recvfrom(char* buf, int len, Host* pHost);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   UDPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */  
+  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(UDPSocketEvent) )
   {
@@ -69,7 +108,8 @@
     m_pCbMeth = (void (CDummy::*)(UDPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent();
 
 protected:
   void onNetUdpSocketEvent(NetUdpSocketEvent e);