Web radiation monitoring system.

Dependencies:   EthernetNetIf TextLCD mbed HTTPServer

Committer:
moritams
Date:
Tue May 24 10:53:04 2011 +0000
Revision:
0:de8fcaf0fc9b
prototype. ver0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
moritams 0:de8fcaf0fc9b 1
moritams 0:de8fcaf0fc9b 2 /*
moritams 0:de8fcaf0fc9b 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
moritams 0:de8fcaf0fc9b 4
moritams 0:de8fcaf0fc9b 5 Permission is hereby granted, free of charge, to any person obtaining a copy
moritams 0:de8fcaf0fc9b 6 of this software and associated documentation files (the "Software"), to deal
moritams 0:de8fcaf0fc9b 7 in the Software without restriction, including without limitation the rights
moritams 0:de8fcaf0fc9b 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
moritams 0:de8fcaf0fc9b 9 copies of the Software, and to permit persons to whom the Software is
moritams 0:de8fcaf0fc9b 10 furnished to do so, subject to the following conditions:
moritams 0:de8fcaf0fc9b 11
moritams 0:de8fcaf0fc9b 12 The above copyright notice and this permission notice shall be included in
moritams 0:de8fcaf0fc9b 13 all copies or substantial portions of the Software.
moritams 0:de8fcaf0fc9b 14
moritams 0:de8fcaf0fc9b 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
moritams 0:de8fcaf0fc9b 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
moritams 0:de8fcaf0fc9b 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
moritams 0:de8fcaf0fc9b 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
moritams 0:de8fcaf0fc9b 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
moritams 0:de8fcaf0fc9b 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
moritams 0:de8fcaf0fc9b 21 THE SOFTWARE.
moritams 0:de8fcaf0fc9b 22 */
moritams 0:de8fcaf0fc9b 23
moritams 0:de8fcaf0fc9b 24 #include "SimpleHandler.h"
moritams 0:de8fcaf0fc9b 25
moritams 0:de8fcaf0fc9b 26 //#define __DEBUG
moritams 0:de8fcaf0fc9b 27 #include "dbg/dbg.h"
moritams 0:de8fcaf0fc9b 28
moritams 0:de8fcaf0fc9b 29 SimpleHandler::SimpleHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket) : HTTPRequestHandler(rootPath, path, pTCPSocket)
moritams 0:de8fcaf0fc9b 30 {}
moritams 0:de8fcaf0fc9b 31
moritams 0:de8fcaf0fc9b 32 SimpleHandler::~SimpleHandler()
moritams 0:de8fcaf0fc9b 33 {
moritams 0:de8fcaf0fc9b 34 DBG("Handler destroyed\r\n");
moritams 0:de8fcaf0fc9b 35 }
moritams 0:de8fcaf0fc9b 36
moritams 0:de8fcaf0fc9b 37 void SimpleHandler::doGet()
moritams 0:de8fcaf0fc9b 38 {
moritams 0:de8fcaf0fc9b 39 DBG("In SimpleHandler::doGet()\r\n");
moritams 0:de8fcaf0fc9b 40 const char* resp = "Hello world !";
moritams 0:de8fcaf0fc9b 41 setContentLen( strlen(resp) );
moritams 0:de8fcaf0fc9b 42 respHeaders()["Connection"] = "close";
moritams 0:de8fcaf0fc9b 43 writeData(resp, strlen(resp));
moritams 0:de8fcaf0fc9b 44 DBG("Exit SimpleHandler::doGet()\r\n");
moritams 0:de8fcaf0fc9b 45 }
moritams 0:de8fcaf0fc9b 46
moritams 0:de8fcaf0fc9b 47 void SimpleHandler::doPost()
moritams 0:de8fcaf0fc9b 48 {
moritams 0:de8fcaf0fc9b 49
moritams 0:de8fcaf0fc9b 50 }
moritams 0:de8fcaf0fc9b 51
moritams 0:de8fcaf0fc9b 52 void SimpleHandler::doHead()
moritams 0:de8fcaf0fc9b 53 {
moritams 0:de8fcaf0fc9b 54
moritams 0:de8fcaf0fc9b 55 }
moritams 0:de8fcaf0fc9b 56
moritams 0:de8fcaf0fc9b 57
moritams 0:de8fcaf0fc9b 58 void SimpleHandler::onReadable() //Data has been read
moritams 0:de8fcaf0fc9b 59 {
moritams 0:de8fcaf0fc9b 60
moritams 0:de8fcaf0fc9b 61 }
moritams 0:de8fcaf0fc9b 62
moritams 0:de8fcaf0fc9b 63 void SimpleHandler::onWriteable() //Data has been written & buf is free
moritams 0:de8fcaf0fc9b 64 {
moritams 0:de8fcaf0fc9b 65 DBG("SimpleHandler::onWriteable() event\r\n");
moritams 0:de8fcaf0fc9b 66 close(); //Data written, we can close the connection
moritams 0:de8fcaf0fc9b 67 }
moritams 0:de8fcaf0fc9b 68
moritams 0:de8fcaf0fc9b 69 void SimpleHandler::onClose() //Connection is closing
moritams 0:de8fcaf0fc9b 70 {
moritams 0:de8fcaf0fc9b 71 //Nothing to do
moritams 0:de8fcaf0fc9b 72 }