test

Dependencies:   EthernetInterface TextLCD mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
y_notsu
Date:
Tue Jan 22 20:46:08 2013 +0000
Commit message:
test

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
LPC1768/HTTPServer.ar Show annotated file Show diff for this revision Revisions of this file
LPC1768/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/HTTPRequestDispatcher.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/HTTPRequestHandler.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/HTTPServer.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/impl/FSHandler.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/impl/RPCHandler.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/server/impl/SimpleHandler.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/util/base64.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/services/http/util/url.h Show annotated file Show diff for this revision Revisions of this file
TextLCD.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-rtos.lib 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/EthernetInterface.lib	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
Binary file LPC1768/HTTPServer.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/dbg/dbg.h	Tue Jan 22 20:46:08 2013 +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/LPC1768/services/http/server/HTTPRequestDispatcher.h	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,72 @@
+
+/*
+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_REQUEST_DISPATCHER_H
+#define HTTP_REQUEST_DISPATCHER_H
+
+class HTTPServer;
+
+#include "api/TCPSocket.h"
+#include "HTTPServer.h"
+#include "core/netservice.h"
+
+#include "mbed.h"
+
+#define HTTP_REQUEST_TIMEOUT 5000
+
+#include <string>
+using std::string;
+
+class HTTPRequestDispatcher : public NetService
+{
+public:
+  HTTPRequestDispatcher(HTTPServer* pSvr, TCPSocket* pTCPSocket);
+  virtual ~HTTPRequestDispatcher();
+  
+private:
+
+  enum HTTP_METH
+  {
+    HTTP_GET,
+    HTTP_POST,
+    HTTP_HEAD
+  };
+  
+  void dispatchRequest();
+  
+  virtual void close(); //Close TCPSocket and destroy data
+  
+  void onTCPSocketEvent(TCPSocketEvent e);
+  
+  void onTimeout(); //Connection has timed out
+
+  bool getRequest(string* path, string* meth);
+  
+  HTTPServer* m_pSvr;
+  TCPSocket* m_pTCPSocket;
+  
+  Timeout m_watchdog;
+  bool m_closed;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/server/HTTPRequestHandler.h	Tue Jan 22 20:46:08 2013 +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.
+*/
+
+/**
+HTTP Request Handler header file.
+*/
+
+#ifndef HTTP_REQUEST_HANDLER_H
+#define HTTP_REQUEST_HANDLER_H
+
+#include "api/TCPSocket.h"
+//#include "HTTPServer.h"
+
+#include "mbed.h"
+#include "core/netservice.h"
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+
+///HTTP Server's generic request handler
+class HTTPRequestHandler : public NetService
+{
+public:
+  ///Instantiated by the HTTP Server
+  HTTPRequestHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
+  virtual ~HTTPRequestHandler();
+
+//protected:
+  virtual void doGet() = 0;
+  virtual void doPost() = 0;
+  virtual void doHead() = 0;
+  
+  virtual void onReadable() = 0; //Data has been read
+  virtual void onWriteable() = 0; //Data has been written & buf is free
+  virtual void onTimeout(); //Connection has timed out
+  virtual void onClose() = 0; //Connection is closing
+  
+  virtual void close(); //Close socket and destroy data
+
+protected:  
+  map<string, string>& reqHeaders() /*const*/;
+  string& path() /*const*/;
+  int dataLen() const;
+  int readData(char* buf, int len);
+  string& rootPath() /*const*/;
+  
+  void setErrCode(int errc);
+  void setContentLen(int len);
+  
+  map<string, string>& respHeaders();
+  int writeData(const char* buf, int len);
+  
+  void setTimeout(int ms);
+  void resetTimeout();
+
+private:
+  void readHeaders(); //Called at instanciation
+  void writeHeaders(); //Called at the first writeData call
+  void onTCPSocketEvent(TCPSocketEvent e);
+   
+  TCPSocket* m_pTCPSocket;
+  map<string, string> m_reqHeaders;
+  map<string, string> m_respHeaders;
+  string m_rootPath;
+  string m_path;
+  int m_errc; //Response code
+  
+  Timeout m_watchdog;
+  int m_timeout;
+  
+  bool m_closed;
+  bool m_headersSent;
+  
+  int readLine(char* str, int maxLen);
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/server/HTTPServer.h	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,104 @@
+
+/*
+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 Server header file
+*/
+
+#ifndef HTTP_SERVER_H
+#define HTTP_SERVER_H
+
+class HTTPRequestHandler;
+class HTTPRequestDispatcher;
+
+#include "core/net.h"
+#include "HTTPRequestHandler.h"
+#include "HTTPRequestDispatcher.h"
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+
+///A simple HTTP server implementation
+/**
+The HTTPServer is composed of:
+- The actual server (HTTPServer)
+- A request dispatcher, instanciated on each request (HTTPRequestDispatcher)
+- Request handlers instanciated by the dispatcher(deriving from HTTPRequestHandler) 
+*/
+class HTTPServer
+{
+public:
+  ///Instantiates the HTTP Server
+  HTTPServer();
+  ~HTTPServer();
+  
+  struct handlersComp //Used to order handlers in the right way
+  {
+    bool operator() (const string& handler1, const string& handler2) const
+    {
+      //The first handler is longer than the second one
+      if (handler1.length() > handler2.length())
+        return true; //Returns true if handler1 is to appear before handler2
+      else if (handler1.length() < handler2.length())
+        return false;
+      else //To avoid the == case, sort now by address
+        return ((&handler1)>(&handler2));
+    }
+  };
+
+  ///Adds a handler
+  /**
+  Appends a handler to the handlers list
+  @param T : class which will be instanciated to serve these requests
+  @param path : requests starting with this path will be served using this handler
+  */
+  template<typename T>
+  void addHandler(const char* path) //Template decl in header
+  { m_lpHandlers[path] = &T::inst; }
+  
+  ///Starts listening
+  /**
+  Binds server to a specific port and starts listening
+  @param port : port on which to listen for incoming connections
+  */
+  void bind(int port = 80);
+  
+private:
+  friend class HTTPRequestDispatcher;
+
+  void onTCPSocketEvent(TCPSocketEvent e);
+  
+  TCPSocket* m_pTCPSocket;
+  map< string, HTTPRequestHandler*(*)(const char*, const char*, TCPSocket*), handlersComp > m_lpHandlers;
+
+};
+
+//Including handlers here for more convenience
+#include "impl/RPCHandler.h"
+#include "impl/FSHandler.h"
+#include "impl/SimpleHandler.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/server/impl/FSHandler.h	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,61 @@
+
+/*
+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 FS_HANDLER_H
+#define FS_HANDLER_H
+
+#include "../HTTPRequestHandler.h"
+#include "mbed.h"
+
+#include <map>
+using std::map;
+
+#include <string>
+using std::string;
+
+class FSHandler : public HTTPRequestHandler
+{
+public:
+  FSHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
+  virtual ~FSHandler();
+  
+  static void mount(const string& fsPath, const string& rootPath);
+
+//protected:
+  static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTCPSocket) { return new FSHandler(rootPath, path, pTCPSocket); } //if we ever could do static virtual functions, this would be one
+
+  virtual void doGet();
+  virtual void doPost();
+  virtual void doHead();
+  
+  virtual void onReadable(); //Data has been read
+  virtual void onWriteable(); //Data has been written & buf is free
+  virtual void onClose(); //Connection is closing
+  
+private:
+  FILE* m_fp;
+  bool m_err404;
+  static map<string,string> m_lFsPath;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/server/impl/RPCHandler.h	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,50 @@
+
+/*
+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 RPC_HANDLER_H
+#define RPC_HANDLER_H
+
+#include "../HTTPRequestHandler.h"
+
+class RPCHandler : public HTTPRequestHandler
+{
+public:
+  RPCHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
+  virtual ~RPCHandler();
+
+//protected:
+  static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTCPSocket) { return new RPCHandler(rootPath, path, pTCPSocket); } //if we ever could do static virtual functions, this would be one
+
+  virtual void doGet();
+  virtual void doPost();
+  virtual void doHead();
+  
+  virtual void onReadable(); //Data has been read
+  virtual void onWriteable(); //Data has been written & buf is free
+  virtual void onClose(); //Connection is closing
+
+protected:
+  void cleanReq(char* data);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/server/impl/SimpleHandler.h	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,47 @@
+
+/*
+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 SIMPLE_HANDLER_H
+#define SIMPLE_HANDLER_H
+
+#include "../HTTPRequestHandler.h"
+
+class SimpleHandler : public HTTPRequestHandler
+{
+public:
+  SimpleHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
+  virtual ~SimpleHandler();
+
+//protected:
+  static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTCPSocket) { return new SimpleHandler(rootPath, path, pTCPSocket); } //if we ever could do static virtual functions, this would be one
+
+  virtual void doGet();
+  virtual void doPost();
+  virtual void doHead();
+  
+  virtual void onReadable(); //Data has been read
+  virtual void onWriteable(); //Data has been written & buf is free
+  virtual void onClose(); //Connection is closing
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/services/http/util/base64.h	Tue Jan 22 20:46:08 2013 +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/LPC1768/services/http/util/url.h	Tue Jan 22 20:46:08 2013 +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/TextLCD.lib	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,102 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "EthernetInterface.h"
+#include "HTTPServer.h"
+
+//EthernetNetIf eth;
+HTTPServer svr;
+DigitalOut myled(LED1);
+TextLCD lcd(p24,p26,p27,p28,p29,p30); //rs,e,d4~d7
+SPI spi(p5, p6, p7); // mosi, miso, sclk
+DigitalOut cs(p8);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+    pc.printf("Startup...\n");
+    lcd.printf("Startup");
+    
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    
+    TCPSocketConnection sock;
+    sock.connect("mbed.org", 80);
+    
+    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    
+    char buffer[300];
+    int ret;
+    while (true) {
+        ret = sock.receive(buffer, sizeof(buffer)-1);
+        if (ret <= 0)
+            break;
+        buffer[ret] = '\0';
+        printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }
+    
+    
+      
+    sock.close();
+    
+    eth.disconnect();
+    
+    pc.printf("Listening...\n");
+    
+    lcd.locate(0,1);
+        // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    spi.format(16,3);
+    spi.frequency(1000000);
+ 
+    // Select the device by seting chip select low
+    cs = 0;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    spi.write(0x0000);
+ 
+    // Send a dummy byte to receive the contents of the WHOAMI register
+    int whoami = spi.write(0x0000);
+    pc.printf("WHOAMI register = 0x%X\n", whoami);
+    lcd.printf("0x%X\n",whoami);
+    // Deselect the device
+    cs = 1;
+    while(1)
+    {
+ 
+    // Select the device by seting chip select low
+    cs = 0;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    //spi.write(0x0000);
+ 
+    // Send a dummy byte to receive the contents of the WHOAMI register
+    int outtemp = spi.write(0x0000);
+    int intemp = spi.write(0x0000);
+    pc.printf("outtemp  = 0x%X\n", outtemp);
+    lcd.locate(0,0);
+    lcd.printf("Out:0x%X\n",outtemp);
+    pc.printf("intemp = 0x%X\n", intemp);
+    lcd.locate(0,1);
+    lcd.printf("In :0x%X",intemp);
+    // Deselect the device
+    cs = 1;
+    float disp;
+    if((outtemp& 0x8000) == 0){ // 0℃以上
+      disp = (outtemp >> 4) * 0.0625;
+    } else {                          // 0℃未満
+      disp = (((0xffff - outtemp) >> 4) + 1)  * -0.0625;
+    }
+    pc.printf("Out:%4.2f[deg]\n",disp);
+    
+    if((intemp& 0x8000) == 0){ // 0℃以上
+      disp = (intemp>> 4) * 0.0625;
+    } else {                          // 0℃未満
+      disp = (((0xffff - intemp) >> 4) + 1)  * -0.0625;
+    }
+    pc.printf("In:%4.2f[deg]\n",disp);
+    wait(10);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#88a1a9c26ae3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jan 22 20:46:08 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/71b101360fb9
\ No newline at end of file