Dependents:   MySQLClientExample MySQLClientExampleMA

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu Aug 05 15:16:36 2010 +0000
Parent:
4:346513288864
Commit message:

Changed in this revision

LPC1768/MySQLClient.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/mysql/MySQLClient.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/mysql/sha1.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/MySQLClient.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/mysql/MySQLClient.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/services/mysql/sha1.h Show annotated file Show diff for this revision Revisions of this file
Binary file LPC1768/MySQLClient.ar has changed
--- a/LPC1768/dbg/dbg.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC1768/dbg/dbg.h	Thu Aug 05 15:16:36 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
 
--- a/LPC1768/services/mysql/MySQLClient.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC1768/services/mysql/MySQLClient.h	Thu Aug 05 15:16:36 2010 +0000
@@ -21,10 +21,15 @@
 THE SOFTWARE.
 */
 
+/** \file
+MySQL Client header file
+*/
+
 #ifndef MYSQL_CLIENT_H
 #define MYSQL_CLIENT_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/netservice.h"
 #include "api/TCPSocket.h"
 #include "api/DNSRequest.h"
 #include "mbed.h"
@@ -37,28 +42,55 @@
 
 typedef unsigned char byte;
 
+///MySQL client results
 enum MySQLResult
 {
-  MYSQL_OK,
-  MYSQL_PROCESSING,
-  MYSQL_PRTCL,
-  MYSQL_SETUP, //Not properly configured
-  MYSQL_DNS, //Could not resolve name
-  MYSQL_AUTHFAILED, //Auth failure
-  MYSQL_READY, //Ready to send commands
-  MYSQL_SQL, //SQL Error
-  MYSQL_TIMEOUT, //Connection timeout
-  MYSQL_CONN //Connection error
+  MYSQL_OK, ///<Success
+  MYSQL_PROCESSING, ///<Processing
+  MYSQL_PRTCL, ///<Protocol error
+  MYSQL_SETUP, ///<Not properly configured
+  MYSQL_DNS, ///<Could not resolve name
+  MYSQL_AUTHFAILED, ///<Auth failure
+  MYSQL_READY, ///<Ready to send commands
+  MYSQL_SQL, ///<SQL Error
+  MYSQL_TIMEOUT, ///<Connection timeout
+  MYSQL_CONN ///<Connection error
 };
 
+///A MySQL Client
+/**
+This MySQL client implements a limited subset of the MySQL internal client/server protocol (including authentication), for server versions 4.1 and newer.
+*/
 class MySQLClient : protected NetService
 {
 public:
+  ///Instantiates the MySQL client
   MySQLClient();
   virtual ~MySQLClient();
   
   //High Level setup functions
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pMethod : callback to call on each request completion
+  */
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, void (*pMethod)(MySQLResult)); //Non blocking
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pItem : callback's class instance
+  @param pMethod : callback's method to call on each request completion
+  */
   template<class T> 
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, T* pItem, void (T::*pMethod)(MySQLResult)) //Non blocking
   {
@@ -67,8 +99,17 @@
     return MYSQL_PROCESSING;
   }
   
+  
+  ///Executes an SQL command
+  /**
+  Executes an SQL request on the SQL server
+  This is a non-blocking function
+  On completion, the callback set in the open function is fired with the result of the command in parameter
+  @param sqlCommand SQL request to execute
+  */
   MySQLResult sql(string& sqlCommand);
   
+  ///Closes the connection to the server
   MySQLResult exit();
       
   void setOnResult( void (*pMethod)(MySQLResult) );
@@ -81,6 +122,10 @@
     m_pCbMeth = (void (CDummy::*)(MySQLResult)) pMethod;
   }
   
+  ///Setups timeout
+  /**
+  @param ms : time of connection inactivity in ms after which the request should timeout
+  */
   void setTimeout(int ms);
   
   virtual void poll(); //Called by NetServices
--- a/LPC1768/services/mysql/sha1.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC1768/services/mysql/sha1.h	Thu Aug 05 15:16:36 2010 +0000
@@ -1,4 +1,4 @@
-/**
+/* 
  * \file sha1.h
  *
  *  Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -21,7 +21,7 @@
 #ifndef POLARSSL_SHA1_H
 #define POLARSSL_SHA1_H
 
-/**
+/* 
  * \brief          SHA-1 context structure
  */
 typedef struct
@@ -39,14 +39,14 @@
 extern "C" {
 #endif
 
-/**
+/* 
  * \brief          SHA-1 context setup
  *
  * \param ctx      context to be initialized
  */
 void sha1_starts( sha1_context *ctx );
 
-/**
+/* 
  * \brief          SHA-1 process buffer
  *
  * \param ctx      SHA-1 context
@@ -55,7 +55,7 @@
  */
 void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen );
 
-/**
+/* 
  * \brief          SHA-1 final digest
  *
  * \param ctx      SHA-1 context
@@ -63,7 +63,7 @@
  */
 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
 
-/**
+/* 
  * \brief          Output = SHA-1( input buffer )
  *
  * \param input    buffer holding the  data
@@ -73,7 +73,7 @@
 void sha1( const unsigned char *input, int ilen, unsigned char output[20] );
 
 #if 0 //No need for that
-/**
+/* 
  * \brief          Output = SHA-1( file contents )
  *
  * \param path     input file name
@@ -85,7 +85,7 @@
 int sha1_file( const char *path, unsigned char output[20] );
 #endif
 
-/**
+/* 
  * \brief          SHA-1 HMAC context setup
  *
  * \param ctx      HMAC context to be initialized
@@ -94,7 +94,7 @@
  */
 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, int keylen );
 
-/**
+/* 
  * \brief          SHA-1 HMAC process buffer
  *
  * \param ctx      HMAC context
@@ -103,7 +103,7 @@
  */
 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, int ilen );
 
-/**
+/* 
  * \brief          SHA-1 HMAC final digest
  *
  * \param ctx      HMAC context
@@ -111,14 +111,14 @@
  */
 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
 
-/**
+/* 
  * \brief          SHA-1 HMAC context reset
  *
  * \param ctx      HMAC context to be reset
  */
 void sha1_hmac_reset( sha1_context *ctx );
 
-/**
+/* 
  * \brief          Output = HMAC-SHA-1( hmac key, input buffer )
  *
  * \param key      HMAC secret key
@@ -131,7 +131,7 @@
                 const unsigned char *input, int ilen,
                 unsigned char output[20] );
 
-/**
+/* 
  * \brief          Checkup routine
  *
  * \return         0 if successful, or 1 if the test failed
Binary file LPC2368/MySQLClient.ar has changed
--- a/LPC2368/dbg/dbg.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC2368/dbg/dbg.h	Thu Aug 05 15:16:36 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
 
--- a/LPC2368/services/mysql/MySQLClient.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC2368/services/mysql/MySQLClient.h	Thu Aug 05 15:16:36 2010 +0000
@@ -21,10 +21,15 @@
 THE SOFTWARE.
 */
 
+/** \file
+MySQL Client header file
+*/
+
 #ifndef MYSQL_CLIENT_H
 #define MYSQL_CLIENT_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/netservice.h"
 #include "api/TCPSocket.h"
 #include "api/DNSRequest.h"
 #include "mbed.h"
@@ -37,28 +42,55 @@
 
 typedef unsigned char byte;
 
+///MySQL client results
 enum MySQLResult
 {
-  MYSQL_OK,
-  MYSQL_PROCESSING,
-  MYSQL_PRTCL,
-  MYSQL_SETUP, //Not properly configured
-  MYSQL_DNS, //Could not resolve name
-  MYSQL_AUTHFAILED, //Auth failure
-  MYSQL_READY, //Ready to send commands
-  MYSQL_SQL, //SQL Error
-  MYSQL_TIMEOUT, //Connection timeout
-  MYSQL_CONN //Connection error
+  MYSQL_OK, ///<Success
+  MYSQL_PROCESSING, ///<Processing
+  MYSQL_PRTCL, ///<Protocol error
+  MYSQL_SETUP, ///<Not properly configured
+  MYSQL_DNS, ///<Could not resolve name
+  MYSQL_AUTHFAILED, ///<Auth failure
+  MYSQL_READY, ///<Ready to send commands
+  MYSQL_SQL, ///<SQL Error
+  MYSQL_TIMEOUT, ///<Connection timeout
+  MYSQL_CONN ///<Connection error
 };
 
+///A MySQL Client
+/**
+This MySQL client implements a limited subset of the MySQL internal client/server protocol (including authentication), for server versions 4.1 and newer.
+*/
 class MySQLClient : protected NetService
 {
 public:
+  ///Instantiates the MySQL client
   MySQLClient();
   virtual ~MySQLClient();
   
   //High Level setup functions
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pMethod : callback to call on each request completion
+  */
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, void (*pMethod)(MySQLResult)); //Non blocking
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pItem : callback's class instance
+  @param pMethod : callback's method to call on each request completion
+  */
   template<class T> 
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, T* pItem, void (T::*pMethod)(MySQLResult)) //Non blocking
   {
@@ -67,8 +99,17 @@
     return MYSQL_PROCESSING;
   }
   
+  
+  ///Executes an SQL command
+  /**
+  Executes an SQL request on the SQL server
+  This is a non-blocking function
+  On completion, the callback set in the open function is fired with the result of the command in parameter
+  @param sqlCommand SQL request to execute
+  */
   MySQLResult sql(string& sqlCommand);
   
+  ///Closes the connection to the server
   MySQLResult exit();
       
   void setOnResult( void (*pMethod)(MySQLResult) );
@@ -81,6 +122,10 @@
     m_pCbMeth = (void (CDummy::*)(MySQLResult)) pMethod;
   }
   
+  ///Setups timeout
+  /**
+  @param ms : time of connection inactivity in ms after which the request should timeout
+  */
   void setTimeout(int ms);
   
   virtual void poll(); //Called by NetServices
--- a/LPC2368/services/mysql/sha1.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC2368/services/mysql/sha1.h	Thu Aug 05 15:16:36 2010 +0000
@@ -1,4 +1,4 @@
-/**
+/* 
  * \file sha1.h
  *
  *  Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -21,7 +21,7 @@
 #ifndef POLARSSL_SHA1_H
 #define POLARSSL_SHA1_H
 
-/**
+/* 
  * \brief          SHA-1 context structure
  */
 typedef struct
@@ -39,14 +39,14 @@
 extern "C" {
 #endif
 
-/**
+/* 
  * \brief          SHA-1 context setup
  *
  * \param ctx      context to be initialized
  */
 void sha1_starts( sha1_context *ctx );
 
-/**
+/* 
  * \brief          SHA-1 process buffer
  *
  * \param ctx      SHA-1 context
@@ -55,7 +55,7 @@
  */
 void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen );
 
-/**
+/* 
  * \brief          SHA-1 final digest
  *
  * \param ctx      SHA-1 context
@@ -63,7 +63,7 @@
  */
 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
 
-/**
+/* 
  * \brief          Output = SHA-1( input buffer )
  *
  * \param input    buffer holding the  data
@@ -73,7 +73,7 @@
 void sha1( const unsigned char *input, int ilen, unsigned char output[20] );
 
 #if 0 //No need for that
-/**
+/* 
  * \brief          Output = SHA-1( file contents )
  *
  * \param path     input file name
@@ -85,7 +85,7 @@
 int sha1_file( const char *path, unsigned char output[20] );
 #endif
 
-/**
+/* 
  * \brief          SHA-1 HMAC context setup
  *
  * \param ctx      HMAC context to be initialized
@@ -94,7 +94,7 @@
  */
 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, int keylen );
 
-/**
+/* 
  * \brief          SHA-1 HMAC process buffer
  *
  * \param ctx      HMAC context
@@ -103,7 +103,7 @@
  */
 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, int ilen );
 
-/**
+/* 
  * \brief          SHA-1 HMAC final digest
  *
  * \param ctx      HMAC context
@@ -111,14 +111,14 @@
  */
 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
 
-/**
+/* 
  * \brief          SHA-1 HMAC context reset
  *
  * \param ctx      HMAC context to be reset
  */
 void sha1_hmac_reset( sha1_context *ctx );
 
-/**
+/* 
  * \brief          Output = HMAC-SHA-1( hmac key, input buffer )
  *
  * \param key      HMAC secret key
@@ -131,7 +131,7 @@
                 const unsigned char *input, int ilen,
                 unsigned char output[20] );
 
-/**
+/* 
  * \brief          Checkup routine
  *
  * \return         0 if successful, or 1 if the test failed