mbed Weather Platform firmware http://mbed.org/users/okini3939/notebook/mbed-weather-platform-firmware/

Dependencies:   EthernetNetIf SDHCFileSystem I2CLEDDisp Agentbed NTPClient_NetServices mbed BMP085 HTTPClient ConfigFile I2CLCD

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Fri Dec 10 17:15:15 2010 +0000
Child:
1:86d4b7431fbe
Commit message:

Changed in this revision

BMP085.lib Show annotated file Show diff for this revision Revisions of this file
ConfigFile.cpp Show annotated file Show diff for this revision Revisions of this file
ConfigFile.h Show annotated file Show diff for this revision Revisions of this file
EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/HTTPClient.ar Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/HTTPClient.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/HTTPData.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/data/HTTPFile.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/data/HTTPMap.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/data/HTTPStream.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/client/data/HTTPText.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/util/base64.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC1768/services/http/util/url.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/HTTPClient.ar Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/HTTPClient.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/HTTPData.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/data/HTTPFile.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/data/HTTPMap.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/data/HTTPStream.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/client/data/HTTPText.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/util/base64.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient/LPC2368/services/http/util/url.h Show annotated file Show diff for this revision Revisions of this file
I2CLCD.lib Show annotated file Show diff for this revision Revisions of this file
NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem/SDFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
SDFileSystem/SDFileSystem.h Show annotated file Show diff for this revision Revisions of this file
SHT_v1/SHT.cpp Show annotated file Show diff for this revision Revisions of this file
SHT_v1/SHT.h Show annotated file Show diff for this revision Revisions of this file
WeatherMeters.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP085.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/BMP085/#6245372b9179
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigFile.cpp	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,166 @@
+#include "ConfigFile.h"
+
+#define BUF_SIZE 100
+
+#define strnicmp strncasecmp
+
+ConfigFile::ConfigFile () {
+    ipaddr = IpAddr(0, 0, 0, 0);
+    netmask = IpAddr(255, 255, 255, 0);
+    gateway = IpAddr(0, 0, 0, 0);
+    nameserver = IpAddr(0, 0, 0, 0);
+    interval = 60;
+    ntpserver[0] = 0;
+    filetype = 0;
+    actionscount = 0;
+    pachube_apikey[0] = 0;
+    pachube_feedid[0] = 0;
+    twitter_user[0] = 0;
+    twitter_pwd[0] = 0;
+}
+
+void ConfigFile::load (char *filename) {
+    char buf[BUF_SIZE];
+    int ip0, ip1, ip2, ip3;
+    FILE *fp;
+
+    fp = fopen(filename, "r");
+    if (fp) {
+        for (;;) {
+            if (feof(fp)) break;
+
+            if (! fgets(buf, BUF_SIZE, fp)) break;
+
+            if (strnicmp(buf, "IPADDRESS=DHCP", 14) == 0) {
+                ipaddr = IpAddr(255, 255, 255, 255);
+            } else
+            if (strnicmp(buf, "IPADDRESS=", 10) == 0) {
+                sscanf(&buf[10], "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
+                ipaddr = IpAddr(ip0, ip1, ip2, ip3);
+            } else
+            if (strnicmp(buf, "NETMASK=", 8) == 0) {
+                sscanf(&buf[10], "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
+                netmask = IpAddr(ip0, ip1, ip2, ip3);
+            } else
+            if (strnicmp(buf, "GATEWAY=", 8) == 0) {
+                sscanf(&buf[10], "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
+                gateway = IpAddr(ip0, ip1, ip2, ip3);
+            } else
+            if (strnicmp(buf, "NAMESERVER=", 11) == 0) {
+                sscanf(&buf[10], "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
+                nameserver = IpAddr(ip0, ip1, ip2, ip3);
+            } else
+            if (strnicmp(buf, "NTPSERVER=", 10) == 0) {
+                strncpy(ntpserver, chop(&buf[10]), sizeof(ntpserver));
+            } else
+            if (strnicmp(buf, "INTERVAL=", 9) == 0) {
+                interval = atoi(&buf[9]);
+            } else
+            if (strnicmp(buf, "FILE=CF", 7) == 0) {
+                filetype = 1;
+            } else
+            if (strnicmp(buf, "FILE=USB", 8) == 0) {
+                filetype = 2;
+            } else
+            if (strnicmp(buf, "ACTION=", 7) == 0) {
+                add(&buf[7]);
+            } else
+            if (strnicmp(buf, "PACHUBE_APIKEY=", 15) == 0) {
+                strncpy(pachube_apikey, chop(&buf[15]), sizeof(pachube_apikey));
+            } else
+            if (strnicmp(buf, "PACHUBE_FEEDID=", 15) == 0) {
+                strncpy(pachube_feedid, chop(&buf[15]), sizeof(pachube_feedid));
+            } else
+            if (strnicmp(buf, "TWITTER_USER=", 13) == 0) {
+                strncpy(twitter_user, chop(&buf[13]), sizeof(twitter_user));
+            } else
+            if (strnicmp(buf, "TWITTER_PWD=", 12) == 0) {
+                strncpy(twitter_pwd, chop(&buf[12]), sizeof(twitter_pwd));
+            }
+        }
+        fclose(fp);
+    }
+}
+
+void ConfigFile::add (char *buf) {
+    int i, len, count;
+    char c;
+    char *tmp = NULL;
+
+    actions[actionscount].action = atoi(&buf[0]);
+
+    count = 0;
+    len = strlen(buf);
+    for (i = 0; i < len; i ++) {
+        c = buf[i];
+        if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
+            buf[i] = 0;
+            if (count) { addsub(&actions[actionscount].exps[count - 1], tmp); }
+            if (count >= CF_ACTION_EXPS || c == '\n') { break; }
+            tmp = &buf[i + 1];
+            count ++;
+        }
+    }
+
+    actions[actionscount].count = count;
+    actionscount ++;
+}
+
+void ConfigFile::addsub (struct tExpression *exp, char *buf) {
+
+    exp->key = buf[0];
+
+    switch (buf[1]) {
+    case '=':
+        if (buf[2] == '=') {
+            exp->expression = EXP_EQ;
+            exp->value = atof(&buf[3]);
+        }
+        break;
+
+    case '!':
+        if (buf[2] == '=') {
+            exp->expression = EXP_NE;
+            exp->value = atof(&buf[3]);
+        }
+        break;
+
+    case '<':
+        if (buf[2] == '=') {
+            exp->expression = EXP_LE;
+            exp->value = atof(&buf[3]);
+        } else {
+            exp->expression = EXP_LT;
+            exp->value = atof(&buf[2]);
+        }
+        break;
+
+    case '>':
+        if (buf[2] == '=') {
+            exp->expression = EXP_GE;
+            exp->value = atof(&buf[3]);
+        } else {
+            exp->expression = EXP_GT;
+            exp->value = atof(&buf[2]);
+        }
+        break;
+
+    default:
+        exp->expression = EXP_NULL;
+        break;
+    }
+}
+
+char* ConfigFile::chop (char *s) {
+    int i, len;
+
+    len = strlen(s);
+    for (i = len - 1; i >= 0; i --) {
+        if (s[i] == '\n' || s[i] == '\r') {
+            s[i] = 0;
+        } else {
+            break;
+        }
+    }
+    return s;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigFile.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+
+#define CF_ACTION_EXPS 10
+#define CF_ACTION_NUM 10
+
+enum eEXPRESSION {
+    EXP_NULL,
+    EXP_EQ,
+    EXP_NE,
+    EXP_LE,
+    EXP_LT,
+    EXP_GE,
+    EXP_GT,
+};
+
+struct tExpression {
+    char key;
+    enum eEXPRESSION expression;
+    float value;
+};
+
+struct tAction {
+    int action;
+    int count;
+    struct tExpression exps[CF_ACTION_EXPS];
+};
+
+class ConfigFile {
+public:
+    int interval;
+    IpAddr ipaddr, netmask, gateway, nameserver;
+    char ntpserver[32];
+    int filetype, actionscount;
+    struct tAction actions[CF_ACTION_NUM];
+    char pachube_apikey[70], pachube_feedid[8];
+    char twitter_user[20], twitter_pwd[20];
+
+    ConfigFile ();
+    void load (char *);
+
+private:
+    void addsub (struct tExpression *, char *);
+    void add (char *);
+    char* chop (char *);
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FATFileSystem.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_unsupported/code/fatfilesystem/
\ No newline at end of file
Binary file HTTPClient/LPC1768/HTTPClient.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/dbg/dbg.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,94 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+Debugging helpers header file
+*/
+
+//#ifdef DBG_H
+//#define DBG_H
+
+#ifdef __LWIP_DEBUG
+#define __DEBUG
+#endif
+
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
+#ifdef __DEBUG
+
+#ifndef __DEBUGSTREAM
+#define __DEBUGSTREAM
+
+
+class DebugStream
+{
+public:
+static void debug(const char* format, ...);
+static void release();
+static void breakPoint(const char* file, int line);
+private:
+
+};
+
+#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
+
+#else
+#undef DBG
+#undef DBG_END
+#undef BREAK
+#define DBG(...)
+#define DBG_END()
+#define BREAK()
+#endif
+
+#ifdef __LWIP_DEBUG
+#ifndef __SNPRINTF
+#define __SNPRINTF
+#include "mbed.h"
+
+//int snprintf(char *str, int size, const char *format, ...);
+#endif
+#endif
+
+#ifdef __LWIP_DEBUG
+#undef __DEBUG
+#endif
+
+//#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/HTTPClient.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,306 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Client header file
+*/
+
+#ifndef HTTP_CLIENT_H
+#define HTTP_CLIENT_H
+
+class HTTPData;
+
+#include "core/net.h"
+#include "api/TCPSocket.h"
+#include "api/DNSRequest.h"
+#include "HTTPData.h"
+#include "mbed.h"
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+
+///HTTP client results
+enum HTTPResult
+{
+  HTTP_OK, ///<Success
+  HTTP_PROCESSING, ///<Processing
+  HTTP_PARSE, ///<URI Parse error
+  HTTP_DNS, ///<Could not resolve name
+  HTTP_PRTCL, ///<Protocol error
+  HTTP_NOTFOUND, ///<HTTP 404 Error
+  HTTP_REFUSED, ///<HTTP 403 Error
+  HTTP_ERROR, ///<HTTP xxx error
+  HTTP_TIMEOUT, ///<Connection timeout
+  HTTP_CONN ///<Connection error
+};
+
+#include "core/netservice.h"
+
+///A simple HTTP Client
+/**
+The HTTPClient is composed of:
+- The actual client (HTTPClient)
+- Classes that act as a data repository, each of which deriving from the HTTPData class (HTTPText for short text content, HTTPFile for file I/O, HTTPMap for key/value pairs, and HTTPStream for streaming purposes)
+*/
+class HTTPClient : protected NetService
+{
+public:
+  ///Instantiates the HTTP client
+  HTTPClient();
+  virtual ~HTTPClient();
+  
+  ///Provides a basic authentification feature (Base64 encoded username and password)
+  void basicAuth(const char* user, const char* password); //Basic Authentification
+  
+  //High Level setup functions
+  ///Executes a GET Request (blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  Blocks until completion
+  */
+  HTTPResult get(const char* uri, HTTPData* pDataIn); //Blocking
+  
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the callback on completion or error
+  */
+  HTTPResult get(const char* uri, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
+  
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @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> 
+  HTTPResult get(const char* uri, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
+  {
+    setOnResult(pItem, pMethod);
+    doGet(uri, pDataIn);
+    return HTTP_PROCESSING;
+  }
+  
+  ///Executes a POST Request (blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  Blocks until completion
+  */
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); //Blocking
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the callback on completion or error
+  */
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @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> 
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking  
+  {
+    setOnResult(pItem, pMethod);
+    doPost(uri, dataOut, pDataIn);
+    return HTTP_PROCESSING;
+  }
+
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  The function returns immediately and calls the previously set callback on completion or error
+  */  
+  void doGet(const char* uri, HTTPData* pDataIn);  
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the previously set callback on completion or error
+  */
+  void doPost(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); 
+  
+  ///Setups the result callback
+  /**
+  @param pMethod : callback function
+  */
+  void setOnResult( void (*pMethod)(HTTPResult) );
+  
+  ///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)(HTTPResult) )
+  {
+    m_pCb = NULL;
+    m_pCbItem = (CDummy*) pItem;
+    m_pCbMeth = (void (CDummy::*)(HTTPResult)) 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
+  
+  ///Gets last request's HTTP response code
+  /**
+  @return The HTTP response code of the last request
+  */
+  int getHTTPResponseCode();
+  
+  ///Sets a specific request header
+  void setRequestHeader(const string& header, const string& value);
+  
+  ///Gets a response header
+  string& getResponseHeader(const string& header);
+  
+  ///Clears request headers
+  void resetRequestHeaders();
+  
+protected:
+  void resetTimeout();
+  
+  void init();
+  void close();
+  
+  void setup(const char* uri, HTTPData* pDataOut, HTTPData* pDataIn); //Setup request, make DNS Req if necessary
+  void connect(); //Start Connection
+  
+  int  tryRead(); //Read data and try to feed output
+  void readData(); //Data has been read
+  void writeData(); //Data has been written & buf is free
+  
+  void onTCPSocketEvent(TCPSocketEvent e);
+  void onDNSReply(DNSReply r);
+  void onResult(HTTPResult r); //Called when exchange completed or on failure
+  void onTimeout(); //Connection has timed out
+  
+private:
+  HTTPResult blockingProcess(); //Called in blocking mode, calls Net::poll() until return code is available
+
+  bool readHeaders(); //Called first when receiving data
+  bool writeHeaders(); //Called to create req
+  int readLine(char* str, int maxLen, bool* pIncomplete = NULL);
+  
+  enum HTTP_METH
+  {
+    HTTP_GET,
+    HTTP_POST,
+    HTTP_HEAD
+  };
+  
+  HTTP_METH m_meth;
+  
+  CDummy* m_pCbItem;
+  void (CDummy::*m_pCbMeth)(HTTPResult);
+  
+  void (*m_pCb)(HTTPResult);
+  
+  TCPSocket* m_pTCPSocket;
+  map<string, string> m_reqHeaders;
+  map<string, string> m_respHeaders;
+  
+  Timer m_watchdog;
+  int m_timeout;
+  
+  DNSRequest* m_pDnsReq;
+  
+  Host m_server;
+  string m_path;
+  
+  bool m_closed;
+  
+  enum HTTPStep
+  {
+   // HTTP_INIT,
+    HTTP_WRITE_HEADERS,
+    HTTP_WRITE_DATA,
+    HTTP_READ_HEADERS,
+    HTTP_READ_DATA,
+    HTTP_READ_DATA_INCOMPLETE,
+    HTTP_DONE,
+    HTTP_CLOSED
+  };
+  
+  HTTPStep m_state;
+  
+  HTTPData* m_pDataOut;
+  HTTPData* m_pDataIn;
+  
+  bool m_dataChunked; //Data is encoded as chunks
+  int m_dataPos; //Position in data
+  int m_dataLen; //Data length
+  char* m_buf;
+  char* m_pBufRemaining; //Remaining
+  int m_bufRemainingLen; //Data length in m_pBufRemaining
+  
+  int m_httpResponseCode;
+  
+  HTTPResult m_blockingResult; //Result if blocking mode
+  
+};
+
+//Including data containers here for more convenience
+#include "data/HTTPFile.h"
+#include "data/HTTPStream.h"
+#include "data/HTTPText.h"
+#include "data/HTTPMap.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/HTTPData.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,58 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HTTP_DATA_H
+#define HTTP_DATA_H
+
+#include "core/net.h"
+
+#include <string>
+using std::string;
+
+class HTTPData //This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
+{
+public:
+  HTTPData();
+  virtual ~HTTPData();
+  
+  virtual void clear() = 0;
+
+protected:
+  friend class HTTPClient;
+  virtual int read(char* buf, int len) = 0;
+  virtual int write(const char* buf, int len) = 0;
+  
+  virtual string getDataType() = 0; //Internet media type for Content-Type header
+  virtual void setDataType(const string& type) = 0; //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked() = 0; //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked) = 0; //From Transfer-Encoding header
+  
+  virtual int getDataLen() = 0; //For Content-Length header
+  virtual void setDataLen(int len) = 0; //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/data/HTTPFile.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,81 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP File data source/sink header file
+*/
+
+#ifndef HTTP_FILE_H
+#define HTTP_FILE_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+///HTTP Client data container for files
+/**
+This class provides file access/storage for HTTP requests and responses' data payloads.
+
+
+*/
+class HTTPFile : public HTTPData //Read or Write data from a file
+{
+public:
+  ///Instantiates data source/sink with file in param.
+  /**
+  Uses file at path @a path.
+  It will be opened when some data has to be read/written from/to it and closed when this operation is complete or on destruction of the instance.
+  Note that the file will be opened with mode "w" for writing and mode "r" for reading, so the file will be cleared between each request if you are using it for writing.
+  
+  @note
+  Note that to use this you must instantiate a proper file system (such as the LocalFileSystem or the SDFileSystem).
+  */
+  HTTPFile(const char* path);
+  virtual ~HTTPFile();
+  
+  ///Forces file closure
+  virtual void clear();
+
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header  virtual
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header
+  
+private:
+  bool openFile(const char* mode); //true on success, false otherwise
+  void closeFile();
+
+  FILE* m_fp;
+  string m_path;
+  int m_len;
+  bool m_chunked;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/data/HTTPMap.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,89 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Map data source/sink header file
+*/
+
+#ifndef HTTP_MAP_H
+#define HTTP_MAP_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+#include <map>
+using std::map;
+
+typedef map<string, string> Dictionary;
+
+///HTTP Client data container for key/value pairs
+/**
+This class simplifies the use of key/value pairs requests and responses used widely among web APIs.
+Note that HTTPMap inherits from std::map<std::string,std::string>.
+You can therefore use any public method of that class, including the square brackets operator ( [ ] ) to access a value.
+
+The data is encoded or decoded to/from a key/value pairs-formatted string, after url-encoding/decoding.
+*/
+class HTTPMap : public HTTPData, public Dictionary //Key/Value pairs
+{
+public:
+  ///Instantiates map
+  /**
+  @param keyValueSep Key/Value separator (defaults to "=")
+  @param pairSep Pairs separator (defaults to "&")
+  */
+  HTTPMap(const string& keyValueSep = "=", const string& pairSep = "&");
+  virtual ~HTTPMap();
+  
+ /* string& operator[](const string& key);
+  int count();*/
+
+  ///Clears the content
+  virtual void clear();  
+  
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header
+  
+private:
+  void generateString();
+  void parseString();
+  //map<string, string> m_map;
+  string m_buf;
+  int m_len;
+  bool m_chunked;
+  
+  string m_keyValueSep;
+  string m_pairSep;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/data/HTTPStream.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,83 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HTTP_STREAM_H
+#define HTTP_STREAM_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+/** \file
+HTTP Stream data source/sink header file
+*/
+
+typedef uint8_t byte;
+
+///HTTP Client Streaming tool
+/**
+This class allows you to stream data from the web using a persisting HTTP connection.
+To use it properly you must use a non-blocking HTTPClient method.
+*/
+class HTTPStream : public HTTPData //Streaming buf
+{
+public:
+  ///Instantiates the object
+  HTTPStream();
+  virtual ~HTTPStream();
+  
+  ///Starts to read into buffer
+  /**
+  Passes a buffer of address @a buf and size @a size to the instance.
+  When it receives data it will be stored in this buffer.
+  When the buffer is full it throttles the client until this function is called again.
+  */
+  void readNext(byte* buf, int size);
+  
+  ///Returns whether there is data available to read
+  bool readable();
+  
+  ///Returns the actual length of the payload written in the buffer
+  int readLen();
+  
+  virtual void clear();
+      
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+  byte* m_buf;
+  int m_size; //Capacity
+  int m_len; //Length
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/client/data/HTTPText.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,101 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Text data source/sink header file
+*/
+
+#ifndef HTTP_TEXT_H
+#define HTTP_TEXT_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+#define DEFAULT_MAX_MEM_ALLOC 512 //Avoid out-of-memory problems
+
+///HTTP Client data container for text
+/**
+This is a simple "Text" data repository for HTTP requests.
+*/
+class HTTPText : public HTTPData //Simple Text I/O
+{
+public:
+  ///Instantiates the object.
+  /**
+  @param encoding encoding of the data, it defaults to text/html.
+  @param maxSize defines the maximum memory size that can be allocated by the object. It defaults to 512 bytes.
+  */
+  HTTPText(const string& encoding = "text/html", int maxSize = DEFAULT_MAX_MEM_ALLOC);
+  virtual ~HTTPText();
+  
+  ///Gets text
+  /**
+  Returns the text in the container as a zero-terminated char*.
+  The array returned points to the internal buffer of the object and remains owned by the object.
+  */
+  const char* gets() const;
+  
+  //Puts text
+  /**
+  Sets the text in the container using a zero-terminated char*.
+  */
+  void puts(const char* str);
+  
+  ///Gets text
+  /**
+  Returns the text in the container as string.
+  */
+  string& get();
+  
+  ///Puts text
+  /**
+  Sets the text in the container as string.
+  */
+  void set(const string& str);
+  
+  ///Clears the content.
+  /**
+  If this container is used as a data sink, it is cleared by the HTTP Client at the beginning of the request.
+  */
+  virtual void clear();
+  
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+  string m_buf;
+  string m_encoding;
+  int m_maxSize;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/util/base64.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,57 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef BASE64_H
+#define BASE64_H
+
+#include <string>
+using std::string;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Originaly from Rolf's iputil.h
+
+unsigned int base64enc_len(const char *str);
+
+void base64enc(const char *input, unsigned int length, char *output);
+
+#ifdef __cplusplus
+}
+#endif
+
+class Base64
+{
+public:
+  static string encode(const string& str)
+  {
+    char* out = new char[ base64enc_len(str.c_str()) ];
+    base64enc(str.c_str(), str.length(), out);
+    string res(out);
+    delete[] out;
+    return res;
+  }
+};
+
+#endif /* LWIP_UTILS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC1768/services/http/util/url.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,88 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef URL_H
+#define URL_H
+
+#include "core/ipaddr.h"
+
+#include <string>
+using std::string;
+
+#include "mbed.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *url_encode(char *str);
+char *url_decode(char *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+class Url
+{
+public:
+  static string encode(const string& url)
+  {
+    char* c_res = url_encode( (char*) url.c_str() );
+    string res(c_res);
+    free(c_res); //Alloc'ed in url_encode()
+    return res;
+  }
+  
+  static string decode(const string& url)
+  {
+    char* c_res = url_decode( (char*) url.c_str() );
+    string res(c_res);
+    free(c_res); //Alloc'ed in url_decode()
+    return res;
+  }
+  
+  Url();
+
+  string getProtocol();
+  string getHost();
+  bool getHostIp(IpAddr* ip); //If host is in IP form, return true & proper object by ptr
+  uint16_t getPort();
+  string getPath();
+  
+  void setProtocol(string protocol);
+  void setHost(string host);
+  void setPort(uint16_t port);
+  void setPath(string path);
+  
+  void fromString(string str);
+  string toString();
+
+private:
+  string m_protocol;
+  string m_host;
+  uint16_t m_port;
+  string m_path;
+  
+};
+
+#endif /* LWIP_UTILS_H */
Binary file HTTPClient/LPC2368/HTTPClient.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/dbg/dbg.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,94 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+Debugging helpers header file
+*/
+
+//#ifdef DBG_H
+//#define DBG_H
+
+#ifdef __LWIP_DEBUG
+#define __DEBUG
+#endif
+
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
+#ifdef __DEBUG
+
+#ifndef __DEBUGSTREAM
+#define __DEBUGSTREAM
+
+
+class DebugStream
+{
+public:
+static void debug(const char* format, ...);
+static void release();
+static void breakPoint(const char* file, int line);
+private:
+
+};
+
+#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
+
+#else
+#undef DBG
+#undef DBG_END
+#undef BREAK
+#define DBG(...)
+#define DBG_END()
+#define BREAK()
+#endif
+
+#ifdef __LWIP_DEBUG
+#ifndef __SNPRINTF
+#define __SNPRINTF
+#include "mbed.h"
+
+//int snprintf(char *str, int size, const char *format, ...);
+#endif
+#endif
+
+#ifdef __LWIP_DEBUG
+#undef __DEBUG
+#endif
+
+//#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/HTTPClient.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,306 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Client header file
+*/
+
+#ifndef HTTP_CLIENT_H
+#define HTTP_CLIENT_H
+
+class HTTPData;
+
+#include "core/net.h"
+#include "api/TCPSocket.h"
+#include "api/DNSRequest.h"
+#include "HTTPData.h"
+#include "mbed.h"
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+
+///HTTP client results
+enum HTTPResult
+{
+  HTTP_OK, ///<Success
+  HTTP_PROCESSING, ///<Processing
+  HTTP_PARSE, ///<URI Parse error
+  HTTP_DNS, ///<Could not resolve name
+  HTTP_PRTCL, ///<Protocol error
+  HTTP_NOTFOUND, ///<HTTP 404 Error
+  HTTP_REFUSED, ///<HTTP 403 Error
+  HTTP_ERROR, ///<HTTP xxx error
+  HTTP_TIMEOUT, ///<Connection timeout
+  HTTP_CONN ///<Connection error
+};
+
+#include "core/netservice.h"
+
+///A simple HTTP Client
+/**
+The HTTPClient is composed of:
+- The actual client (HTTPClient)
+- Classes that act as a data repository, each of which deriving from the HTTPData class (HTTPText for short text content, HTTPFile for file I/O, HTTPMap for key/value pairs, and HTTPStream for streaming purposes)
+*/
+class HTTPClient : protected NetService
+{
+public:
+  ///Instantiates the HTTP client
+  HTTPClient();
+  virtual ~HTTPClient();
+  
+  ///Provides a basic authentification feature (Base64 encoded username and password)
+  void basicAuth(const char* user, const char* password); //Basic Authentification
+  
+  //High Level setup functions
+  ///Executes a GET Request (blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  Blocks until completion
+  */
+  HTTPResult get(const char* uri, HTTPData* pDataIn); //Blocking
+  
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the callback on completion or error
+  */
+  HTTPResult get(const char* uri, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
+  
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @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> 
+  HTTPResult get(const char* uri, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
+  {
+    setOnResult(pItem, pMethod);
+    doGet(uri, pDataIn);
+    return HTTP_PROCESSING;
+  }
+  
+  ///Executes a POST Request (blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  Blocks until completion
+  */
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); //Blocking
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the callback on completion or error
+  */
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @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> 
+  HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking  
+  {
+    setOnResult(pItem, pMethod);
+    doPost(uri, dataOut, pDataIn);
+    return HTTP_PROCESSING;
+  }
+
+  ///Executes a GET Request (non blocking)
+  /**
+  Executes a GET request on the URI uri
+  @param uri : URI on which to execute the request
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  The function returns immediately and calls the previously set callback on completion or error
+  */  
+  void doGet(const char* uri, HTTPData* pDataIn);  
+  
+  ///Executes a POST Request (non blocking)
+  /**
+  Executes a POST request on the URI uri
+  @param uri : URI on which to execute the request
+  @param dataOut : a HTTPData instance that contains the data that will be posted
+  @param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
+  @param pMethod : callback function
+  The function returns immediately and calls the previously set callback on completion or error
+  */
+  void doPost(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); 
+  
+  ///Setups the result callback
+  /**
+  @param pMethod : callback function
+  */
+  void setOnResult( void (*pMethod)(HTTPResult) );
+  
+  ///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)(HTTPResult) )
+  {
+    m_pCb = NULL;
+    m_pCbItem = (CDummy*) pItem;
+    m_pCbMeth = (void (CDummy::*)(HTTPResult)) 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
+  
+  ///Gets last request's HTTP response code
+  /**
+  @return The HTTP response code of the last request
+  */
+  int getHTTPResponseCode();
+  
+  ///Sets a specific request header
+  void setRequestHeader(const string& header, const string& value);
+  
+  ///Gets a response header
+  string& getResponseHeader(const string& header);
+  
+  ///Clears request headers
+  void resetRequestHeaders();
+  
+protected:
+  void resetTimeout();
+  
+  void init();
+  void close();
+  
+  void setup(const char* uri, HTTPData* pDataOut, HTTPData* pDataIn); //Setup request, make DNS Req if necessary
+  void connect(); //Start Connection
+  
+  int  tryRead(); //Read data and try to feed output
+  void readData(); //Data has been read
+  void writeData(); //Data has been written & buf is free
+  
+  void onTCPSocketEvent(TCPSocketEvent e);
+  void onDNSReply(DNSReply r);
+  void onResult(HTTPResult r); //Called when exchange completed or on failure
+  void onTimeout(); //Connection has timed out
+  
+private:
+  HTTPResult blockingProcess(); //Called in blocking mode, calls Net::poll() until return code is available
+
+  bool readHeaders(); //Called first when receiving data
+  bool writeHeaders(); //Called to create req
+  int readLine(char* str, int maxLen, bool* pIncomplete = NULL);
+  
+  enum HTTP_METH
+  {
+    HTTP_GET,
+    HTTP_POST,
+    HTTP_HEAD
+  };
+  
+  HTTP_METH m_meth;
+  
+  CDummy* m_pCbItem;
+  void (CDummy::*m_pCbMeth)(HTTPResult);
+  
+  void (*m_pCb)(HTTPResult);
+  
+  TCPSocket* m_pTCPSocket;
+  map<string, string> m_reqHeaders;
+  map<string, string> m_respHeaders;
+  
+  Timer m_watchdog;
+  int m_timeout;
+  
+  DNSRequest* m_pDnsReq;
+  
+  Host m_server;
+  string m_path;
+  
+  bool m_closed;
+  
+  enum HTTPStep
+  {
+   // HTTP_INIT,
+    HTTP_WRITE_HEADERS,
+    HTTP_WRITE_DATA,
+    HTTP_READ_HEADERS,
+    HTTP_READ_DATA,
+    HTTP_READ_DATA_INCOMPLETE,
+    HTTP_DONE,
+    HTTP_CLOSED
+  };
+  
+  HTTPStep m_state;
+  
+  HTTPData* m_pDataOut;
+  HTTPData* m_pDataIn;
+  
+  bool m_dataChunked; //Data is encoded as chunks
+  int m_dataPos; //Position in data
+  int m_dataLen; //Data length
+  char* m_buf;
+  char* m_pBufRemaining; //Remaining
+  int m_bufRemainingLen; //Data length in m_pBufRemaining
+  
+  int m_httpResponseCode;
+  
+  HTTPResult m_blockingResult; //Result if blocking mode
+  
+};
+
+//Including data containers here for more convenience
+#include "data/HTTPFile.h"
+#include "data/HTTPStream.h"
+#include "data/HTTPText.h"
+#include "data/HTTPMap.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/HTTPData.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,58 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HTTP_DATA_H
+#define HTTP_DATA_H
+
+#include "core/net.h"
+
+#include <string>
+using std::string;
+
+class HTTPData //This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
+{
+public:
+  HTTPData();
+  virtual ~HTTPData();
+  
+  virtual void clear() = 0;
+
+protected:
+  friend class HTTPClient;
+  virtual int read(char* buf, int len) = 0;
+  virtual int write(const char* buf, int len) = 0;
+  
+  virtual string getDataType() = 0; //Internet media type for Content-Type header
+  virtual void setDataType(const string& type) = 0; //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked() = 0; //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked) = 0; //From Transfer-Encoding header
+  
+  virtual int getDataLen() = 0; //For Content-Length header
+  virtual void setDataLen(int len) = 0; //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/data/HTTPFile.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,81 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP File data source/sink header file
+*/
+
+#ifndef HTTP_FILE_H
+#define HTTP_FILE_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+///HTTP Client data container for files
+/**
+This class provides file access/storage for HTTP requests and responses' data payloads.
+
+
+*/
+class HTTPFile : public HTTPData //Read or Write data from a file
+{
+public:
+  ///Instantiates data source/sink with file in param.
+  /**
+  Uses file at path @a path.
+  It will be opened when some data has to be read/written from/to it and closed when this operation is complete or on destruction of the instance.
+  Note that the file will be opened with mode "w" for writing and mode "r" for reading, so the file will be cleared between each request if you are using it for writing.
+  
+  @note
+  Note that to use this you must instantiate a proper file system (such as the LocalFileSystem or the SDFileSystem).
+  */
+  HTTPFile(const char* path);
+  virtual ~HTTPFile();
+  
+  ///Forces file closure
+  virtual void clear();
+
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header  virtual
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header
+  
+private:
+  bool openFile(const char* mode); //true on success, false otherwise
+  void closeFile();
+
+  FILE* m_fp;
+  string m_path;
+  int m_len;
+  bool m_chunked;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/data/HTTPMap.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,89 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Map data source/sink header file
+*/
+
+#ifndef HTTP_MAP_H
+#define HTTP_MAP_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+#include <map>
+using std::map;
+
+typedef map<string, string> Dictionary;
+
+///HTTP Client data container for key/value pairs
+/**
+This class simplifies the use of key/value pairs requests and responses used widely among web APIs.
+Note that HTTPMap inherits from std::map<std::string,std::string>.
+You can therefore use any public method of that class, including the square brackets operator ( [ ] ) to access a value.
+
+The data is encoded or decoded to/from a key/value pairs-formatted string, after url-encoding/decoding.
+*/
+class HTTPMap : public HTTPData, public Dictionary //Key/Value pairs
+{
+public:
+  ///Instantiates map
+  /**
+  @param keyValueSep Key/Value separator (defaults to "=")
+  @param pairSep Pairs separator (defaults to "&")
+  */
+  HTTPMap(const string& keyValueSep = "=", const string& pairSep = "&");
+  virtual ~HTTPMap();
+  
+ /* string& operator[](const string& key);
+  int count();*/
+
+  ///Clears the content
+  virtual void clear();  
+  
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+  
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header
+  
+private:
+  void generateString();
+  void parseString();
+  //map<string, string> m_map;
+  string m_buf;
+  int m_len;
+  bool m_chunked;
+  
+  string m_keyValueSep;
+  string m_pairSep;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/data/HTTPStream.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,83 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HTTP_STREAM_H
+#define HTTP_STREAM_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+/** \file
+HTTP Stream data source/sink header file
+*/
+
+typedef uint8_t byte;
+
+///HTTP Client Streaming tool
+/**
+This class allows you to stream data from the web using a persisting HTTP connection.
+To use it properly you must use a non-blocking HTTPClient method.
+*/
+class HTTPStream : public HTTPData //Streaming buf
+{
+public:
+  ///Instantiates the object
+  HTTPStream();
+  virtual ~HTTPStream();
+  
+  ///Starts to read into buffer
+  /**
+  Passes a buffer of address @a buf and size @a size to the instance.
+  When it receives data it will be stored in this buffer.
+  When the buffer is full it throttles the client until this function is called again.
+  */
+  void readNext(byte* buf, int size);
+  
+  ///Returns whether there is data available to read
+  bool readable();
+  
+  ///Returns the actual length of the payload written in the buffer
+  int readLen();
+  
+  virtual void clear();
+      
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+  byte* m_buf;
+  int m_size; //Capacity
+  int m_len; //Length
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/client/data/HTTPText.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,101 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/** \file
+HTTP Text data source/sink header file
+*/
+
+#ifndef HTTP_TEXT_H
+#define HTTP_TEXT_H
+
+#include "../HTTPData.h"
+#include "mbed.h"
+
+#define DEFAULT_MAX_MEM_ALLOC 512 //Avoid out-of-memory problems
+
+///HTTP Client data container for text
+/**
+This is a simple "Text" data repository for HTTP requests.
+*/
+class HTTPText : public HTTPData //Simple Text I/O
+{
+public:
+  ///Instantiates the object.
+  /**
+  @param encoding encoding of the data, it defaults to text/html.
+  @param maxSize defines the maximum memory size that can be allocated by the object. It defaults to 512 bytes.
+  */
+  HTTPText(const string& encoding = "text/html", int maxSize = DEFAULT_MAX_MEM_ALLOC);
+  virtual ~HTTPText();
+  
+  ///Gets text
+  /**
+  Returns the text in the container as a zero-terminated char*.
+  The array returned points to the internal buffer of the object and remains owned by the object.
+  */
+  const char* gets() const;
+  
+  //Puts text
+  /**
+  Sets the text in the container using a zero-terminated char*.
+  */
+  void puts(const char* str);
+  
+  ///Gets text
+  /**
+  Returns the text in the container as string.
+  */
+  string& get();
+  
+  ///Puts text
+  /**
+  Sets the text in the container as string.
+  */
+  void set(const string& str);
+  
+  ///Clears the content.
+  /**
+  If this container is used as a data sink, it is cleared by the HTTP Client at the beginning of the request.
+  */
+  virtual void clear();
+  
+protected:
+  virtual int read(char* buf, int len);
+  virtual int write(const char* buf, int len);
+  
+  virtual string getDataType(); //Internet media type for Content-Type header
+  virtual void setDataType(const string& type); //Internet media type from Content-Type header
+
+  virtual bool getIsChunked(); //For Transfer-Encoding header
+  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
+  
+  virtual int getDataLen(); //For Content-Length header
+  virtual void setDataLen(int len); //From Content-Length header, or if the transfer is chunked, next chunk length
+  
+private:
+  string m_buf;
+  string m_encoding;
+  int m_maxSize;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/util/base64.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,57 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef BASE64_H
+#define BASE64_H
+
+#include <string>
+using std::string;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Originaly from Rolf's iputil.h
+
+unsigned int base64enc_len(const char *str);
+
+void base64enc(const char *input, unsigned int length, char *output);
+
+#ifdef __cplusplus
+}
+#endif
+
+class Base64
+{
+public:
+  static string encode(const string& str)
+  {
+    char* out = new char[ base64enc_len(str.c_str()) ];
+    base64enc(str.c_str(), str.length(), out);
+    string res(out);
+    delete[] out;
+    return res;
+  }
+};
+
+#endif /* LWIP_UTILS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient/LPC2368/services/http/util/url.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,88 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef URL_H
+#define URL_H
+
+#include "core/ipaddr.h"
+
+#include <string>
+using std::string;
+
+#include "mbed.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *url_encode(char *str);
+char *url_decode(char *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+class Url
+{
+public:
+  static string encode(const string& url)
+  {
+    char* c_res = url_encode( (char*) url.c_str() );
+    string res(c_res);
+    free(c_res); //Alloc'ed in url_encode()
+    return res;
+  }
+  
+  static string decode(const string& url)
+  {
+    char* c_res = url_decode( (char*) url.c_str() );
+    string res(c_res);
+    free(c_res); //Alloc'ed in url_decode()
+    return res;
+  }
+  
+  Url();
+
+  string getProtocol();
+  string getHost();
+  bool getHostIp(IpAddr* ip); //If host is in IP form, return true & proper object by ptr
+  uint16_t getPort();
+  string getPath();
+  
+  void setProtocol(string protocol);
+  void setHost(string host);
+  void setPort(uint16_t port);
+  void setPath(string path);
+  
+  void fromString(string str);
+  string toString();
+
+private:
+  string m_protocol;
+  string m_host;
+  uint16_t m_port;
+  string m_path;
+  
+};
+
+#endif /* LWIP_UTILS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2CLCD.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/I2CLCD/#b069b7027af2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem/SDFileSystem.cpp	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,457 @@
+/* mbed SDFileSystem Library, for providing file access to SD cards
+ * Copyright (c) 2008-2010, sford
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* Introduction
+ * ------------
+ * SD and MMC cards support a number of interfaces, but common to them all
+ * is one based on SPI. This is the one I'm implmenting because it means
+ * it is much more portable even though not so performant, and we already 
+ * have the mbed SPI Interface!
+ *
+ * The main reference I'm using is Chapter 7, "SPI Mode" of: 
+ *  http://www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf
+ *
+ * SPI Startup
+ * -----------
+ * The SD card powers up in SD mode. The SPI interface mode is selected by
+ * asserting CS low and sending the reset command (CMD0). The card will 
+ * respond with a (R1) response.
+ *
+ * CMD8 is optionally sent to determine the voltage range supported, and 
+ * indirectly determine whether it is a version 1.x SD/non-SD card or 
+ * version 2.x. I'll just ignore this for now.
+ *
+ * ACMD41 is repeatedly issued to initialise the card, until "in idle"
+ * (bit 0) of the R1 response goes to '0', indicating it is initialised.
+ *
+ * You should also indicate whether the host supports High Capicity cards,
+ * and check whether the card is high capacity - i'll also ignore this
+ *
+ * SPI Protocol
+ * ------------
+ * The SD SPI protocol is based on transactions made up of 8-bit words, with
+ * the host starting every bus transaction by asserting the CS signal low. The
+ * card always responds to commands, data blocks and errors.
+ * 
+ * The protocol supports a CRC, but by default it is off (except for the 
+ * first reset CMD0, where the CRC can just be pre-calculated, and CMD8)
+ * I'll leave the CRC off I think! 
+ * 
+ * Standard capacity cards have variable data block sizes, whereas High 
+ * Capacity cards fix the size of data block to 512 bytes. I'll therefore
+ * just always use the Standard Capacity cards with a block size of 512 bytes.
+ * This is set with CMD16.
+ *
+ * You can read and write single blocks (CMD17, CMD25) or multiple blocks 
+ * (CMD18, CMD25). For simplicity, I'll just use single block accesses. When
+ * the card gets a read command, it responds with a response token, and then 
+ * a data token or an error.
+ * 
+ * SPI Command Format
+ * ------------------
+ * Commands are 6-bytes long, containing the command, 32-bit argument, and CRC.
+ *
+ * +---------------+------------+------------+-----------+----------+--------------+
+ * | 01 | cmd[5:0] | arg[31:24] | arg[23:16] | arg[15:8] | arg[7:0] | crc[6:0] | 1 |
+ * +---------------+------------+------------+-----------+----------+--------------+
+ *
+ * As I'm not using CRC, I can fix that byte to what is needed for CMD0 (0x95)
+ *
+ * All Application Specific commands shall be preceded with APP_CMD (CMD55).
+ *
+ * SPI Response Format
+ * -------------------
+ * The main response format (R1) is a status byte (normally zero). Key flags:
+ *  idle - 1 if the card is in an idle state/initialising 
+ *  cmd  - 1 if an illegal command code was detected
+ *
+ *    +-------------------------------------------------+
+ * R1 | 0 | arg | addr | seq | crc | cmd | erase | idle |
+ *    +-------------------------------------------------+
+ *
+ * R1b is the same, except it is followed by a busy signal (zeros) until
+ * the first non-zero byte when it is ready again.
+ *
+ * Data Response Token
+ * -------------------
+ * Every data block written to the card is acknowledged by a byte 
+ * response token
+ *
+ * +----------------------+
+ * | xxx | 0 | status | 1 |
+ * +----------------------+
+ *              010 - OK!
+ *              101 - CRC Error
+ *              110 - Write Error
+ *
+ * Single Block Read and Write
+ * ---------------------------
+ *
+ * Block transfers have a byte header, followed by the data, followed
+ * by a 16-bit CRC. In our case, the data will always be 512 bytes.
+ *  
+ * +------+---------+---------+- -  - -+---------+-----------+----------+
+ * | 0xFE | data[0] | data[1] |        | data[n] | crc[15:8] | crc[7:0] | 
+ * +------+---------+---------+- -  - -+---------+-----------+----------+
+ */
+ 
+#include "SDFileSystem.h"
+
+#define SD_COMMAND_TIMEOUT 5000
+
+SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
+  FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs) {
+      _cs = 1; 
+}
+
+#define R1_IDLE_STATE           (1 << 0)
+#define R1_ERASE_RESET          (1 << 1)
+#define R1_ILLEGAL_COMMAND      (1 << 2)
+#define R1_COM_CRC_ERROR        (1 << 3)
+#define R1_ERASE_SEQUENCE_ERROR (1 << 4)
+#define R1_ADDRESS_ERROR        (1 << 5)
+#define R1_PARAMETER_ERROR      (1 << 6)
+
+// Types
+//  - v1.x Standard Capacity
+//  - v2.x Standard Capacity
+//  - v2.x High Capacity
+//  - Not recognised as an SD Card
+
+#define SDCARD_FAIL 0
+#define SDCARD_V1   1
+#define SDCARD_V2   2
+#define SDCARD_V2HC 3
+
+int SDFileSystem::initialise_card() {
+    // Set to 100kHz for initialisation, and clock card with cs = 1
+    _spi.frequency(100000); 
+    _cs = 1;
+    for(int i=0; i<16; i++) {   
+        _spi.write(0xFF);
+    }
+
+    // send CMD0, should return with all zeros except IDLE STATE set (bit 0)
+    if(_cmd(0, 0) != R1_IDLE_STATE) { 
+        fprintf(stderr, "No disk, or could not put SD card in to SPI idle state\n");
+        return SDCARD_FAIL;
+    }
+
+    // send CMD8 to determine whther it is ver 2.x
+    int r = _cmd8();
+    if(r == R1_IDLE_STATE) {
+        return initialise_card_v2();
+    } else if(r == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) {
+        return initialise_card_v1();
+    } else {
+        fprintf(stderr, "Not in idle state after sending CMD8 (not an SD card?)\n");
+        return SDCARD_FAIL;
+    }
+}
+
+int SDFileSystem::initialise_card_v1() {
+    for(int i=0; i<SD_COMMAND_TIMEOUT; i++) {
+        _cmd(55, 0); 
+        if(_cmd(41, 0) == 0) { 
+            return SDCARD_V1;
+        }
+    }
+
+    fprintf(stderr, "Timeout waiting for v1.x card\n");
+    return SDCARD_FAIL;
+}
+
+int SDFileSystem::initialise_card_v2() {
+    
+    for(int i=0; i<SD_COMMAND_TIMEOUT; i++) {
+        _cmd(55, 0); 
+        if(_cmd(41, 0) == 0) { 
+            _cmd58();
+            return SDCARD_V2;
+        }
+    }
+
+    fprintf(stderr, "Timeout waiting for v2.x card\n");
+    return SDCARD_FAIL;
+}
+
+int SDFileSystem::disk_initialize() {
+
+    int i = initialise_card();
+//    printf("init card = %d\n", i);
+//    printf("OK\n");
+
+    _sectors = _sd_sectors();
+
+    // Set block length to 512 (CMD16)
+    if(_cmd(16, 512) != 0) {
+        fprintf(stderr, "Set 512-byte block timed out\n");
+        return 1;
+    }
+        
+    _spi.frequency(1000000); // Set to 1MHz for data transfer
+    return 0;
+}
+
+int SDFileSystem::disk_write(const char *buffer, int block_number) {
+    // set write address for single block (CMD24)
+    if(_cmd(24, block_number * 512) != 0) {
+        return 1;
+    }
+
+    // send the data block
+    _write(buffer, 512);    
+    return 0;    
+}
+
+int SDFileSystem::disk_read(char *buffer, int block_number) {        
+    // set read address for single block (CMD17)
+    if(_cmd(17, block_number * 512) != 0) {
+        return 1;
+    }
+    
+    // receive the data
+    _read(buffer, 512);
+    return 0;
+}
+
+int SDFileSystem::disk_status() { return 0; }
+int SDFileSystem::disk_sync() { return 0; }
+int SDFileSystem::disk_sectors() { return _sectors; }
+
+// PRIVATE FUNCTIONS
+
+int SDFileSystem::_cmd(int cmd, int arg) {
+    _cs = 0; 
+
+    // send a command
+    _spi.write(0x40 | cmd);
+    _spi.write(arg >> 24);
+    _spi.write(arg >> 16);
+    _spi.write(arg >> 8);
+    _spi.write(arg >> 0);
+    _spi.write(0x95);
+
+    // wait for the repsonse (response[7] == 0)
+    for(int i=0; i<SD_COMMAND_TIMEOUT; i++) {
+        int response = _spi.write(0xFF);
+        if(!(response & 0x80)) {
+            _cs = 1;
+            _spi.write(0xFF);
+            return response;
+        }
+    }
+    _cs = 1;
+    _spi.write(0xFF);
+    return -1; // timeout
+}
+int SDFileSystem::_cmdx(int cmd, int arg) {
+    _cs = 0; 
+
+    // send a command
+    _spi.write(0x40 | cmd);
+    _spi.write(arg >> 24);
+    _spi.write(arg >> 16);
+    _spi.write(arg >> 8);
+    _spi.write(arg >> 0);
+    _spi.write(0x95);
+
+    // wait for the repsonse (response[7] == 0)
+    for(int i=0; i<SD_COMMAND_TIMEOUT; i++) {
+        int response = _spi.write(0xFF);
+        if(!(response & 0x80)) {
+            return response;
+        }
+    }
+    _cs = 1;
+    _spi.write(0xFF);
+    return -1; // timeout
+}
+
+
+int SDFileSystem::_cmd58() {
+    _cs = 0; 
+    int arg = 0;
+    
+    // send a command
+    _spi.write(0x40 | 58);
+    _spi.write(arg >> 24);
+    _spi.write(arg >> 16);
+    _spi.write(arg >> 8);
+    _spi.write(arg >> 0);
+    _spi.write(0x95);
+
+    // wait for the repsonse (response[7] == 0)
+    for(int i=0; i<SD_COMMAND_TIMEOUT; i++) {
+        int response = _spi.write(0xFF);
+        if(!(response & 0x80)) {
+            int ocr = _spi.write(0xFF) << 24;
+            ocr |= _spi.write(0xFF) << 16;
+            ocr |= _spi.write(0xFF) << 8;
+            ocr |= _spi.write(0xFF) << 0;
+//            printf("OCR = 0x%08X\n", ocr);
+            _cs = 1;
+            _spi.write(0xFF);
+            return response;
+        }
+    }
+    _cs = 1;
+    _spi.write(0xFF);
+    return -1; // timeout
+}
+
+int SDFileSystem::_cmd8() {
+    _cs = 0; 
+    
+    // send a command
+    _spi.write(0x40 | 8); // CMD8
+    _spi.write(0x00);     // reserved
+    _spi.write(0x00);     // reserved
+    _spi.write(0x01);     // 3.3v
+    _spi.write(0xAA);     // check pattern
+    _spi.write(0x87);     // crc
+
+    // wait for the repsonse (response[7] == 0)
+    for(int i=0; i<SD_COMMAND_TIMEOUT * 1000; i++) {
+        char response[5];
+        response[0] = _spi.write(0xFF);
+        if(!(response[0] & 0x80)) {
+                for(int j=1; j<5; j++) {
+                    response[i] = _spi.write(0xFF);
+                }
+                _cs = 1;
+                _spi.write(0xFF);
+                return response[0];
+        }
+    }
+    _cs = 1;
+    _spi.write(0xFF);
+    return -1; // timeout
+}
+
+int SDFileSystem::_read(char *buffer, int length) {
+    _cs = 0;
+
+    // read until start byte (0xFF)
+    while(_spi.write(0xFF) != 0xFE);
+
+    // read data
+    for(int i=0; i<length; i++) {
+        buffer[i] = _spi.write(0xFF);
+    }
+    _spi.write(0xFF); // checksum
+    _spi.write(0xFF);
+
+    _cs = 1;    
+    _spi.write(0xFF);
+    return 0;
+}
+
+int SDFileSystem::_write(const char *buffer, int length) {
+    _cs = 0;
+    
+    // indicate start of block
+    _spi.write(0xFE);
+    
+    // write the data
+    for(int i=0; i<length; i++) {
+        _spi.write(buffer[i]);
+    }
+    
+    // write the checksum
+    _spi.write(0xFF); 
+    _spi.write(0xFF);
+
+    // check the repsonse token
+    if((_spi.write(0xFF) & 0x1F) != 0x05) {
+        _cs = 1;
+        _spi.write(0xFF);        
+        return 1;
+    }
+
+    // wait for write to finish
+    while(_spi.write(0xFF) == 0);
+
+    _cs = 1; 
+    _spi.write(0xFF);
+    return 0;
+}
+
+static int ext_bits(char *data, int msb, int lsb) {
+    int bits = 0;
+    int size = 1 + msb - lsb; 
+    for(int i=0; i<size; i++) {
+        int position = lsb + i;
+        int byte = 15 - (position >> 3);
+        int bit = position & 0x7;
+        int value = (data[byte] >> bit) & 1;
+        bits |= value << i;
+    }
+    return bits;
+}
+
+int SDFileSystem::_sd_sectors() {
+
+    // CMD9, Response R2 (R1 byte + 16-byte block read)
+    if(_cmdx(9, 0) != 0) {
+        fprintf(stderr, "Didn't get a response from the disk\n");
+        return 0;
+    }
+    
+    char csd[16];    
+    if(_read(csd, 16) != 0) {
+        fprintf(stderr, "Couldn't read csd response from disk\n");
+        return 0;
+    }
+
+    // csd_structure : csd[127:126]
+    // c_size        : csd[73:62]
+    // c_size_mult   : csd[49:47]
+    // read_bl_len   : csd[83:80] - the *maximum* read block length
+
+    int csd_structure = ext_bits(csd, 127, 126);
+    int c_size = ext_bits(csd, 73, 62);
+    int c_size_mult = ext_bits(csd, 49, 47);
+    int read_bl_len = ext_bits(csd, 83, 80);
+
+//    printf("CSD_STRUCT = %d\n", csd_structure);
+    
+    if(csd_structure != 0) {
+        fprintf(stderr, "This disk tastes funny! I only know about type 0 CSD structures\n");
+        return 0;
+    }
+             
+    // memory capacity = BLOCKNR * BLOCK_LEN
+    // where
+    //  BLOCKNR = (C_SIZE+1) * MULT
+    //  MULT = 2^(C_SIZE_MULT+2) (C_SIZE_MULT < 8)
+    //  BLOCK_LEN = 2^READ_BL_LEN, (READ_BL_LEN < 12)         
+                            
+    int block_len = 1 << read_bl_len;
+    int mult = 1 << (c_size_mult + 2);
+    int blocknr = (c_size + 1) * mult;
+    int capacity = blocknr * block_len;
+        
+    int blocks = capacity / 512;
+        
+    return blocks;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem/SDFileSystem.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,81 @@
+/* mbed SDFileSystem Library, for providing file access to SD cards
+ * Copyright (c) 2008-2010, sford
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MBED_SDFILESYSTEM_H
+#define MBED_SDFILESYSTEM_H
+
+#include "mbed.h"
+#include "FATFileSystem.h"
+
+/** Access the filesystem on an SD Card using SPI
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "SDFileSystem.h"
+ *
+ * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs
+ *  
+ * int main() {
+ *     FILE *fp = fopen("/sd/myfile.txt", "w");
+ *     fprintf(fp, "Hello World!\n");
+ *     fclose(fp);
+ * }
+ */
+class SDFileSystem : public FATFileSystem {
+public:
+
+    /** Create the File System for accessing an SD Card using SPI
+     *
+     * @param mosi SPI mosi pin connected to SD Card
+     * @param miso SPI miso pin conencted to SD Card
+     * @param sclk SPI sclk pin connected to SD Card
+     * @param cs   DigitalOut pin used as SD Card chip select
+     * @param name The name used to access the virtual filesystem
+     */
+    SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
+    virtual int disk_initialize();
+    virtual int disk_write(const char *buffer, int block_number);
+    virtual int disk_read(char *buffer, int block_number);    
+    virtual int disk_status();
+    virtual int disk_sync();
+    virtual int disk_sectors();
+
+protected:
+
+    int _cmd(int cmd, int arg);
+    int _cmdx(int cmd, int arg);
+    int _cmd8();
+    int _cmd58();
+    int initialise_card();
+    int initialise_card_v1();
+    int initialise_card_v2();
+    
+    int _read(char *buffer, int length);
+    int _write(const char *buffer, int length);
+    int _sd_sectors();
+    int _sectors;
+    
+    SPI _spi;
+    DigitalOut _cs;     
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHT_v1/SHT.cpp	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,224 @@
+/* mbed module to use a Sensirion SHT1x /SHT7x sensor
+ * Copyright (c) 2007-2009 Stephen McGarry
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
+#include "SHT.h"
+
+#include "mbed.h"
+
+SHT::SHT(PinName p_sclk, PinName p_data, SHT_acc p_accuracy) : sclk(p_sclk), data(p_data), accuracy(p_accuracy) {
+    sclk=0;
+    data=0;               // data pin will be used as open collector pin
+    data.mode(PullUp);    // with the pull up internally active
+    data.input();        // with line released to go high
+    temperature = humidity = dewpoint=0.0f;
+   printf("constructor\n");
+}
+
+char SHT::write_byte(byte value)
+//----------------------------------------------------------------------------------
+// writes a byte on the Sensibus and checks the acknowledge
+{
+    int i;
+    char error=0;
+
+    for (i=0x80;i>0;i/=2) {           //shift bit for masking
+        if (i & value) data.input();  //masking value with i , write to SENSI-BUS
+        else data.output();
+        wait_us(1);                   //ensure sclk is low for min time
+        sclk=1;                       //clk for SENSI-BUS
+        wait_us(1);                   //pulsewith approx. 2 us
+        sclk=0;
+    }
+    data.input();                     //release DATA-line
+    wait_us(1);                       //ensure sclk is low for min time
+    sclk=1;                           //clk #9 for ack
+    error=data;                       //check ack (DATA will be pulled down by SHT11)
+    wait_us(1);
+    sclk=0;
+    return error;                     //error=1 in case of no acknowledge
+}
+
+byte SHT::read_byte(bool send_ack)
+//----------------------------------------------------------------------------------
+// reads a byte form the Sensibus and gives an acknowledge in case of "ack=1"
+{
+    byte i,val=0;
+    data.input();                     //release DATA-line
+    for (i=0x80;i>0;i/=2) {           //shift bit for masking
+        wait_us(1);
+        sclk=1;                       //clk for SENSI-BUS
+        if (data) val=(val | i);      //read bit
+        wait_us(1);
+        sclk=0;
+    }
+    wait_us(1);
+    if (send_ack) data.output();      // if ack needed then drive data low
+    sclk=1;                           //clk #9 for ack
+    wait_us(1);
+    sclk=0;
+    data.input();                     //release DATA-line
+    return val;
+}
+
+void SHT::trans_start(void)
+//----------------------------------------------------------------------------------
+// generates a transmission start
+//       _____         ________
+// DATA:      |_______|
+//           ___     ___
+// SCK : ___|   |___|   |______
+{
+    data.input();
+    sclk=0;                   //Initial state
+    wait_us(1);
+    sclk=1;
+    wait_us(1);
+    data.output();            // data low
+    wait_us(1);
+    sclk=0;
+    wait_us(1);
+    sclk=1;
+    wait_us(1);
+    data.input();            // allow data to high
+    wait_us(1);
+    sclk=0;
+    wait_us(1);
+}
+
+void SHT::connection_reset(void)
+//----------------------------------------------------------------------------------
+// communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart
+//       _____________________________________________________         ________
+// DATA:                                                      |_______|
+//          _    _    _    _    _    _    _    _    _        ___     ___
+// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______|   |___|   |______
+{
+    int i;
+    data.input();            // allow data high
+    sclk=0;                  // and clk low
+    for (i=0;i<9;i++) {      // 9 SCK cycles
+        wait_us(1);
+        sclk=1;
+        wait_us(1);
+        sclk=0;
+    }
+}
+char SHT::soft_reset(void)
+//----------------------------------------------------------------------------------
+// resets the sensor by a softreset
+{
+    char error=0;
+    SHT::connection_reset();                //reset communication
+    trans_start();
+    error+=write_byte(com_reset);       //send RESET-command to sensor
+    return error;                     //error=1 in case of no response form the sensor
+}
+
+char SHT::read_status(byte &value)
+//----------------------------------------------------------------------------------
+// reads the status register with checksum (8-bit)
+{
+    //byte checksum;
+
+    char error=0;
+    trans_start();                     //transmission start
+    error=write_byte(com_read_status_reg); //send command to sensor
+    value=read_byte(send_ack);             //read status register (8-bit)
+    /* checksum= */
+    (void)read_byte(no_ack);         //read checksum (8-bit)
+    // check the checksum ??
+    return error;                      //error=1 in case of no response form the sensor
+}
+
+char SHT::write_status(byte value)
+//----------------------------------------------------------------------------------
+// writes the status register (8-bit)
+{
+    char error=0;
+    trans_start();                        //transmission start
+    error+=write_byte(com_write_status_reg); //send command to sensor
+    error+=write_byte(value);            //send value of status register
+    return error;                          //error>=1 in case of no response form the sensor
+}
+
+char SHT::measure(int &value, byte command)
+//----------------------------------------------------------------------------------
+// makes a measurement (humidity/temperature) with checksum
+{
+    unsigned int i;
+    byte msb;
+    // byte checksum;
+
+    trans_start();                //transmission start
+    if (write_byte(command)) return 1; // if command fails return
+
+    for (i=10000;i;i--) {          //wait until sensor has finished the measurement
+        wait_us(100);
+        if (data==0) break;
+    }
+    if (data) return 1;            // or timeout (~1 sec.) is reached !!
+    msb = read_byte(send_ack);         //read the first byte (MSB)
+    value = msb*256 + read_byte(send_ack);    //read the second byte (LSB)
+    /* checksum= */
+    (void)read_byte(no_ack);    //read checksum
+    return 0;
+}
+
+void SHT::calculate()
+//----------------------------------------------------------------------------------------
+// calculates temperature [°C] and humidity [%RH]
+// input :  hum  [Ticks] (12 bit)
+//          temp [Ticks] (14 bit)
+// output:  humidity [%RH]
+//          temperature [°C]
+{
+    const float C1=-4.0;              // for 12 Bit
+    const float C2=+0.0405;           // for 12 Bit
+    const float C3=-0.0000028;        // for 12 Bit
+    //const float T1=+0.01;             // for 14 Bit @ 5V
+    //const float T2=+0.00008;           // for 14 Bit @ 5V
+
+    float rh;                         // rh:      Humidity [Ticks] 12 Bit
+    float t;                          // t:       Temperature [Ticks] 14 Bit
+    //float rh_lin;                     // rh_lin:  Humidity linear
+    if (accuracy==SHT_low) {
+        rh=hum*16;                    // rescale to high accuracy values - 8 to 12 bits
+        t=temp*4;                     // and 12 to 14 bits
+    } else {
+        rh=hum;
+        t=temp;
+    }
+
+    temperature=t*0.01 - 40;                  //calc. temperature from ticks to [°C]
+    humidity=C3*rh*rh + C2*rh + C1;     //calc. humidity from ticks to [%RH]
+    // =(temperature-25)*(T1+T2*rh)+rh_lin;   //calc. temperature compensated humidity [%RH] (ignore as never >0.25%)
+    if (humidity>100)humidity=100;      //cut if the value is outside of
+    if (humidity<0.1)humidity=0.1;      //the physical possible range
+}
+
+float SHT::get_temperature() {     // get the most recent temp reading
+    return temperature;
+}
+
+float SHT::get_humidity() {        // get the most recent humidity reading
+    return humidity;
+}
+
+float SHT::get_dewpoint() {        // get the most recent dewpoint value
+    return dewpoint;
+}
+
+void SHT::update(SHT_acc acc) {   // update stored values from sensor
+    int error=0;
+    connection_reset();
+    if (acc!=accuracy) {
+        accuracy=acc;
+        error+=write_status((acc==SHT_low)?0x01:0x00);    //set the status reg to high or low accuarcy
+    }
+    error+=measure(temp,com_measure_temp);
+    error+=measure(hum,com_measure_humid);
+    if (!error) calculate();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHT_v1/SHT.h	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,66 @@
+/* mbed module to use a Sensirion SHT1x /SHT7x sensor
+ * Copyright (c) 2007-2009 Stephen McGarry
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+#ifndef SHT_H
+#define SHT_H
+
+#include "mbed.h"
+
+enum SHT_acc {
+    SHT_low=0,
+    SHT_high=1
+};
+
+typedef unsigned char byte;
+
+class SHT : public Base {
+public:
+    /* Constructor: SHT
+     *  Creates an SHT interface connected to specific pins.
+     *
+     */
+    SHT(PinName p_sclk, PinName p_data, SHT_acc p_accuracy);
+
+    /* Functions
+     */
+    float get_temperature();     // get the most recent temp reading
+    float get_humidity();        // get the most recent humidity reading
+    float get_dewpoint();        // get the most recent dewpoint value
+    void update(SHT_acc accuracy); // update stored values from sensor
+
+protected:
+    byte read_byte(bool send_ack);
+    char write_byte(byte value);
+    void trans_start(void);
+    void connection_reset(void);
+    char soft_reset();
+    char read_status(byte &value);
+    char write_status(byte value);
+    char measure(int &value, byte mode);
+    void calculate();
+
+    DigitalOut sclk;
+    DigitalInOut data;
+    SHT_acc accuracy;    // will we use high or low accuracy mode on the sensor
+
+    float temperature;    // calculated from sensor reading
+    float humidity;
+    float dewpoint;
+    int temp,hum;        // integer values from sensor before conversion
+
+    enum commands {
+        com_read_status_reg=0x06,
+        com_write_status_reg=0x07,
+        com_measure_temp=0x03,
+        com_measure_humid=0x05,
+        com_reset=0x1E
+    };
+
+    enum acks {
+        no_ack=0,
+        send_ack=1
+    };
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WeatherMeters.lib	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/WeatherMeters/#dc42aeff64e6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,299 @@
+/*
+ * mbed Weather Platform
+ * Copyright (c) 2010 Hiroshi Suga
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+/** mbed Weather Platform
+ * @auther Suga koubou Co.,Ltd.
+ */
+#include "mbed.h"
+#include "BMP085.h"
+#include "SHT.h"
+#include "WeatherMeters.h"
+//#include "I2CLCD.h"
+#include "ConfigFile.h"
+#include "SDFileSystem.h"
+#include "EthernetNetIf.h"
+#include "NTPClient.h"
+#include "HTTPClient.h"
+
+#define VERSION "mbed Weather Platform 0.1a (C) 2010 Suga koubou Co.,Ltd."
+#define TIMEZONE 9
+
+//#define NONBLOCKING
+
+Serial pc(USBTX, USBRX);
+int seq = 0;
+char filename[20];
+ConfigFile conf;
+DigitalOut led1(LED1), led2(LED2), led3(LED3);
+SDFileSystem sd(p5, p6, p7, p8, "sd"); 
+
+// Sensors
+float pres, temp, humi, light, anemo, vane, rain, uv, moist, temp2;
+I2C i2c(p9, p10);
+BMP085 bmp085(i2c, BMP085_oss4);
+//I2CLCD i2clcd(i2c);
+SHT sht15(p12, p11, SHT_high); // sclock, data
+WeatherMeters wmeters(p21, p15, p22); // anemo, vane, rain
+AnalogIn ailight(p16), aimoist(p18), aiuv(p17);
+
+// Ethernet
+EthernetNetIf *eth; 
+NTPClient *ntp;
+HTTPClient *clientP;
+DigitalOut led_g(p25), led_y(p26);
+DigitalIn eth_link(P1_25), eth_speed(P1_26);
+
+
+float get_photo (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0 / 1000; // A
+    return f / 0.0000026; // lx
+}
+
+float get_moist (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0; // V
+    return f / ((3.3 - f) / 10.0); // k ohm
+}
+
+float get_uv (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0 / 100000; // A
+    return f / 0.000384; // mW/cm2
+}
+
+void writefile (char *buf) {
+    FILE *fp;
+
+    led3 = 1;
+    fp = fopen(filename, "a");
+    if (fp) {
+        fprintf(fp, buf);
+        fclose(fp);
+    } else {
+        led2 = 0;
+        conf.filetype = 0;
+    }
+    led3 = 0;
+}
+
+void cb_clientP (HTTPResult status) {
+    if (status != HTTP_OK) {
+        pc.printf("Pachube failure (%d)\r\n", status);
+//        pc.printf("Pachube failure (%d, %d)\r\n", status, clientP->getHTTPResponseCode());
+    }
+}
+
+void pachube (char *buf) {
+    char uri[100];
+    HTTPText csvContent("text/csv");
+
+    led3 = 1;
+    clientP->setRequestHeader("X-PachubeApiKey", conf.pachube_apikey);
+    csvContent.set(buf);
+    strcpy(uri, "http://api.pachube.com/v1/feeds/");
+    strcat(uri, conf.pachube_feedid);
+    strcat(uri, ".csv?_method=put");
+#ifdef NONBLOCKING
+    Net::poll();
+    clientP->post(uri, csvContent, NULL, &cb_clientP);
+    Net::poll();
+#else
+    clientP->post(uri, csvContent, NULL);
+#endif
+    led3 = 0;
+}
+
+void cb_settime (NTPResult status) {
+    if (status == NTP_OK) {
+        time_t sec = time(NULL) + (60 * 60 * TIMEZONE);
+        set_time(sec);
+        pc.printf("Ntp success: %s\r\n", ctime(&sec));
+    } else {
+        pc.printf("Ntp failure (%d)\r\n", status);
+    }
+//    ntp->close();
+}
+
+void ntpdate () {
+    ntp = new NTPClient;
+    Host ntpserver(IpAddr(), 123, conf.ntpserver);
+
+#ifdef NONBLOCKING
+    Net::poll();
+    ntp->setTime(ntpserver, &cb_settime);
+    Net::poll();
+#else
+    ntp->setTime(ntpserver);
+    time_t sec = time(NULL) + (60 * 60 * TIMEZONE);
+    set_time(sec);
+#endif
+}
+
+void init () {
+    FILE *fp;
+
+    conf.load("/sd/weather.cf");
+
+    if (conf.ipaddr[0]) {
+        // use ethernet
+
+        eth_link.mode(PullUp);
+        eth_speed.mode(PullUp);
+        led_g = eth_link ? 1 : 0;
+        led_y = eth_speed ? 1 : 0;
+        if (conf.ipaddr[0] == 255) {
+            // dhcp
+            eth = new EthernetNetIf;
+        } else {
+            // static
+            eth = new EthernetNetIf(conf.ipaddr, conf.netmask, conf.gateway, conf.nameserver);
+        }
+
+        EthernetErr ethErr = eth->setup();
+        if(ethErr) {
+            // error
+            conf.ipaddr = IpAddr(0, 0, 0, 0);
+        } else
+        if (conf.ipaddr[0] == 255) {
+            // succeed dhcp
+            conf.ipaddr = eth->getIp();
+        }
+        pc.printf("Ethernet: %d.%d.%d.%d\r\n", eth->getIp()[0], eth->getIp()[1], eth->getIp()[2], eth->getIp()[3]);
+
+        if (conf.ipaddr[0] && conf.ntpserver[0]) {
+            // ntp
+            pc.printf("Ntp: %s\r\n", conf.ntpserver);
+            ntpdate();
+        }
+        
+        if (conf.ipaddr[0]) {
+            clientP = new HTTPClient;
+        }
+    }
+
+    if (conf.filetype) {
+        // seq num
+        fp = fopen("/sd/weather.seq", "r");
+        if (fp) {
+            fscanf(fp, "%d", &seq);
+            fclose(fp);
+        }
+        seq ++;
+        fp = fopen("/sd/weather.seq", "w");
+        if (fp) {
+            fprintf(fp, "%d", seq);
+            fclose(fp);
+            // create csv filename
+            if (conf.filetype == 1) {
+                sprintf(filename, "/sd/w%05d.csv", seq);
+            } else
+            if (conf.filetype == 2) {
+                sprintf(filename, "/usb/w%05d.csv", seq);
+            }
+            pc.printf("Filename: %s\r\n", filename);
+            led2 = 1;
+        }
+    }
+}
+
+int main () {
+    int i;
+    Timer timer;
+    time_t sec;
+    char buf[100];
+    
+    led1 = 1;
+    init();
+    pc.printf(VERSION "\r\n\r\n");
+    pc.printf("[%s|%s|%s|%s]\r\n", conf.pachube_apikey, conf.pachube_feedid, conf.twitter_user, conf.twitter_pwd);
+
+    if (conf.filetype) {
+        strcpy(buf, "date,pres(hPa),temp(`C),humi(%%),anemo(m/s),vane(`),rain(mm),light(lx),uv(mW/cm2),moist(kohm),\r\n");
+        writefile(buf);
+    }
+    
+    timer.start();
+#ifdef NONBLOCKING
+    while (timer.read() < 5) {
+        Net::poll();
+    }
+    timer.reset();
+#endif
+    
+    while(1) {
+        led1 = 0;
+
+        sec = time(NULL);
+        strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&sec));
+
+        // sensors
+        bmp085.update();
+        pres = bmp085.get_pressure();
+        temp2 = bmp085.get_temperature();
+
+        sht15.update(SHT_high);
+        temp = sht15.get_temperature();
+        humi = sht15.get_humidity();
+
+        anemo = wmeters.get_windspeed();
+        vane = wmeters.get_windvane();
+        rain = wmeters.get_raingauge();
+
+        light = get_photo(ailight);
+        moist = get_moist(aimoist);
+        uv = get_uv(aiuv);
+/*
+        i2clcd.locate(0, 0);
+        i2clcd.printf("%4.1f hPa", p);
+        i2clcd.locate(0, 1);
+        i2clcd.printf("%2.1f C / %2.1f %%", t, h);
+*/
+
+        sprintf(&buf[strlen(buf)], ",%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f\r\n", pres, temp, humi, anemo, vane, rain, light, uv, moist, temp2);
+        pc.printf(buf);
+        if (conf.filetype) {
+            // csv
+            writefile(buf);
+        }
+/*
+        if (actionscount) {
+            // pin action
+            i = check_action();
+            if (i == 0) {
+                outpin = 0;
+            } else
+            if (i == 1) {
+                outpin = 1;
+            }
+        }
+*/
+        if (conf.ipaddr[0]) {
+            if (conf.pachube_apikey[0] && conf.pachube_feedid[0]) {
+                // pachube
+                pachube(&buf[20]);
+            }
+            if (conf.twitter_user[0] && conf.twitter_pwd[0]) {
+                // twitter
+            }
+        }
+
+        led1 = 1;
+
+        while (timer.read() < conf.interval) {
+//            wait(1);
+//            pc.putc('.');
+            led_g = eth_link ? 1 : 0;
+            led_y = eth_speed ? 1 : 0;
+#ifdef NONBLOCKING
+            Net::poll();
+#endif
+        }
+        timer.reset();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 10 17:15:15 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e