EthernetNetIf Compatibility.

Dependents:   XBeeWiFi_SPI_example

Fork of NetServicesSource by Donatien Garnier

Revision:
5:dd63a1e02b1b
Parent:
4:fd826cad83c0
--- a/services/mysql/MySQLClient.cpp	Fri Jul 09 14:46:47 2010 +0000
+++ b/services/mysql/MySQLClient.cpp	Tue Jul 27 15:59:42 2010 +0000
@@ -28,7 +28,7 @@
 //#define __DEBUG
 #include "dbg/dbg.h"
 
-#define MYSQL_TIMEOUT_MS 15000
+#define MYSQL_TIMEOUT_MS 45000
 #define MYSQL_PORT 3306
 
 #define BUF_SIZE 256
@@ -188,26 +188,25 @@
   m_password = password;
   
   m_db = db;
-  
-  IpAddr ip;
+
   if( !host.getIp().isNull() )
   {
     connect();
   }
   else //Need to do a DNS Query...
   {
-    DBG("\r\nDNS Query...\r\n");
+    DBG("DNS Query...\n");
     m_pDnsReq = new DNSRequest();
     m_pDnsReq->setOnReply(this, &MySQLClient::onDNSReply);
     m_pDnsReq->resolve(&m_host);
-    DBG("\r\nMySQLClient : DNSRequest %p\r\n", m_pDnsReq);
+    DBG("MySQLClient : DNSRequest %p\n", m_pDnsReq);
   }
 }
 
 void MySQLClient::connect() //Start Connection
 {
   resetTimeout();
-  DBG("\r\nConnecting...\r\n");
+  DBG("Connecting...\n");
   m_pTCPSocket->connect(m_host);
   m_packetId = 0;
 }
@@ -442,11 +441,11 @@
 
 void MySQLClient::onTCPSocketEvent(TCPSocketEvent e)
 {
-  DBG("\r\nEvent %d in MySQLClient::onTCPSocketEvent()\r\n", e);
+  DBG("Event %d in MySQLClient::onTCPSocketEvent()\n", e);
 
   if(m_closed)
   {
-    DBG("\r\nWARN: Discarded\r\n");
+    DBG("WARN: Discarded\n");
     return;
   }
   
@@ -471,7 +470,7 @@
   case TCPSOCKET_CONRST:
   case TCPSOCKET_CONABRT:
   case TCPSOCKET_ERROR:
-    DBG("\r\nConnection error.\r\n");
+    DBG("Connection error.\n");
     onResult(MYSQL_CONN);
   case TCPSOCKET_DISCONNECTED:
     //There might still be some data available for reading
@@ -480,7 +479,7 @@
     {
       onResult(MYSQL_CONN);
     }
-    DBG("\r\nConnection closed by remote host.\r\n");
+    DBG("Connection closed by remote host.\n");
     break;
   }
 }
@@ -489,18 +488,18 @@
 {
   if(m_closed)
   {
-    DBG("\r\nWARN: Discarded\r\n");
+    DBG("WARN: Discarded\n");
     return;
   }
   
   if( r != DNS_FOUND )
   {
-    DBG("\r\nCould not resolve hostname.\r\n");
+    DBG("Could not resolve hostname.\n");
     onResult(MYSQL_DNS);
     return;
   }
   
-  DBG("\r\nDNS Resolved to %d.%d.%d.%d.\r\n",m_host.getIp()[0],m_host.getIp()[1],m_host.getIp()[2],m_host.getIp()[3]);
+  DBG("DNS Resolved to %d.%d.%d.%d.\n",m_host.getIp()[0],m_host.getIp()[1],m_host.getIp()[2],m_host.getIp()[3]);
   //If no error, m_host has been updated by m_pDnsReq so we're set to go !
   m_pDnsReq->close();
   delete m_pDnsReq;
@@ -521,7 +520,7 @@
 
 void MySQLClient::onTimeout() //Connection has timed out
 {
-  DBG("\r\nTimed out.\n");
-  onResult(MYSQL_DNS);
+  DBG("Timed out.\n");
+  onResult(MYSQL_TIMEOUT);
   close();
 }