Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 10 19:56:45 2011 +0000
Revision:
1:b26ab2467b1a
Parent:
0:8d62137f7ff4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benecsj 0:8d62137f7ff4 1
benecsj 0:8d62137f7ff4 2 /*
benecsj 0:8d62137f7ff4 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
benecsj 0:8d62137f7ff4 4
benecsj 0:8d62137f7ff4 5 Permission is hereby granted, free of charge, to any person obtaining a copy
benecsj 0:8d62137f7ff4 6 of this software and associated documentation files (the "Software"), to deal
benecsj 0:8d62137f7ff4 7 in the Software without restriction, including without limitation the rights
benecsj 0:8d62137f7ff4 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
benecsj 0:8d62137f7ff4 9 copies of the Software, and to permit persons to whom the Software is
benecsj 0:8d62137f7ff4 10 furnished to do so, subject to the following conditions:
benecsj 0:8d62137f7ff4 11
benecsj 0:8d62137f7ff4 12 The above copyright notice and this permission notice shall be included in
benecsj 0:8d62137f7ff4 13 all copies or substantial portions of the Software.
benecsj 0:8d62137f7ff4 14
benecsj 0:8d62137f7ff4 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
benecsj 0:8d62137f7ff4 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
benecsj 0:8d62137f7ff4 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
benecsj 0:8d62137f7ff4 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
benecsj 0:8d62137f7ff4 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
benecsj 0:8d62137f7ff4 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
benecsj 0:8d62137f7ff4 21 THE SOFTWARE.
benecsj 0:8d62137f7ff4 22 */
benecsj 0:8d62137f7ff4 23
benecsj 0:8d62137f7ff4 24 #ifndef HTTP_REQUEST_DISPATCHER_H
benecsj 0:8d62137f7ff4 25 #define HTTP_REQUEST_DISPATCHER_H
benecsj 0:8d62137f7ff4 26
benecsj 0:8d62137f7ff4 27 class HTTPServer;
benecsj 0:8d62137f7ff4 28
benecsj 0:8d62137f7ff4 29 #include "api/TCPSocket.h"
benecsj 0:8d62137f7ff4 30 #include "HTTPServer.h"
benecsj 0:8d62137f7ff4 31 #include "core/netservice.h"
benecsj 0:8d62137f7ff4 32
benecsj 0:8d62137f7ff4 33 #include "mbed.h"
benecsj 0:8d62137f7ff4 34
benecsj 0:8d62137f7ff4 35 #define HTTP_REQUEST_TIMEOUT 10000
benecsj 0:8d62137f7ff4 36
benecsj 0:8d62137f7ff4 37 #include <string>
benecsj 0:8d62137f7ff4 38 using std::string;
benecsj 0:8d62137f7ff4 39
benecsj 0:8d62137f7ff4 40
benecsj 0:8d62137f7ff4 41
benecsj 0:8d62137f7ff4 42 class HTTPRequestDispatcher : public NetService
benecsj 0:8d62137f7ff4 43 {
benecsj 0:8d62137f7ff4 44 public:
benecsj 0:8d62137f7ff4 45 HTTPRequestDispatcher(HTTPServer* pSvr, TCPSocket* pTCPSocket);
benecsj 0:8d62137f7ff4 46 virtual ~HTTPRequestDispatcher();
benecsj 0:8d62137f7ff4 47
benecsj 0:8d62137f7ff4 48 private:
benecsj 0:8d62137f7ff4 49
benecsj 0:8d62137f7ff4 50 enum HTTP_METH
benecsj 0:8d62137f7ff4 51 {
benecsj 0:8d62137f7ff4 52 HTTP_GET,
benecsj 0:8d62137f7ff4 53 HTTP_POST,
benecsj 0:8d62137f7ff4 54 HTTP_HEAD
benecsj 0:8d62137f7ff4 55 };
benecsj 0:8d62137f7ff4 56
benecsj 0:8d62137f7ff4 57 void dispatchRequest();
benecsj 0:8d62137f7ff4 58
benecsj 0:8d62137f7ff4 59 virtual void close(); //Close TCPSocket and destroy data
benecsj 0:8d62137f7ff4 60
benecsj 0:8d62137f7ff4 61 void onTCPSocketEvent(TCPSocketEvent e);
benecsj 0:8d62137f7ff4 62
benecsj 0:8d62137f7ff4 63 void onTimeout(); //Connection has timed out
benecsj 0:8d62137f7ff4 64
benecsj 0:8d62137f7ff4 65 bool getRequest(string* path, string* meth);
benecsj 0:8d62137f7ff4 66
benecsj 0:8d62137f7ff4 67 HTTPServer* m_pSvr;
benecsj 0:8d62137f7ff4 68 TCPSocket* m_pTCPSocket;
benecsj 0:8d62137f7ff4 69
benecsj 0:8d62137f7ff4 70 Timeout m_watchdog;
benecsj 0:8d62137f7ff4 71 bool m_closed;
benecsj 0:8d62137f7ff4 72 };
benecsj 0:8d62137f7ff4 73
benecsj 0:8d62137f7ff4 74 #endif