Give water to plants if dry amd pla meanwhile music the music vou can define with note length bind and breake also select several instruments for the sound

Dependencies:   mbed

Committer:
helmut
Date:
Wed Sep 19 14:16:56 2012 +0000
Revision:
0:5150b09127e3
plays mostly music that you can do with notes length breakes and bind; Some already defined; Tool is to start a pump for water to give plant is too dry.; Meanwhie plays music the most part of all

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helmut 0:5150b09127e3 1
helmut 0:5150b09127e3 2 /*
helmut 0:5150b09127e3 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
helmut 0:5150b09127e3 4
helmut 0:5150b09127e3 5 Permission is hereby granted, free of charge, to any person obtaining a copy
helmut 0:5150b09127e3 6 of this software and associated documentation files (the "Software"), to deal
helmut 0:5150b09127e3 7 in the Software without restriction, including without limitation the rights
helmut 0:5150b09127e3 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
helmut 0:5150b09127e3 9 copies of the Software, and to permit persons to whom the Software is
helmut 0:5150b09127e3 10 furnished to do so, subject to the following conditions:
helmut 0:5150b09127e3 11
helmut 0:5150b09127e3 12 The above copyright notice and this permission notice shall be included in
helmut 0:5150b09127e3 13 all copies or substantial portions of the Software.
helmut 0:5150b09127e3 14
helmut 0:5150b09127e3 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
helmut 0:5150b09127e3 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
helmut 0:5150b09127e3 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
helmut 0:5150b09127e3 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
helmut 0:5150b09127e3 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
helmut 0:5150b09127e3 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
helmut 0:5150b09127e3 21 THE SOFTWARE.
helmut 0:5150b09127e3 22 */
helmut 0:5150b09127e3 23
helmut 0:5150b09127e3 24 /**
helmut 0:5150b09127e3 25 HTTP Request Handler header file.
helmut 0:5150b09127e3 26 */
helmut 0:5150b09127e3 27
helmut 0:5150b09127e3 28 #ifndef HTTP_REQUEST_HANDLER_H
helmut 0:5150b09127e3 29 #define HTTP_REQUEST_HANDLER_H
helmut 0:5150b09127e3 30
helmut 0:5150b09127e3 31 #include "api/TCPSocket.h"
helmut 0:5150b09127e3 32 //#include "HTTPServer.h"
helmut 0:5150b09127e3 33
helmut 0:5150b09127e3 34 #include "mbed.h"
helmut 0:5150b09127e3 35 #include "core/netservice.h"
helmut 0:5150b09127e3 36
helmut 0:5150b09127e3 37 #include <string>
helmut 0:5150b09127e3 38 using std::string;
helmut 0:5150b09127e3 39
helmut 0:5150b09127e3 40 #include <map>
helmut 0:5150b09127e3 41 using std::map;
helmut 0:5150b09127e3 42
helmut 0:5150b09127e3 43 ///HTTP Server's generic request handler
helmut 0:5150b09127e3 44 class HTTPRequestHandler : public NetService
helmut 0:5150b09127e3 45 {
helmut 0:5150b09127e3 46 public:
helmut 0:5150b09127e3 47 ///Instantiated by the HTTP Server
helmut 0:5150b09127e3 48 HTTPRequestHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
helmut 0:5150b09127e3 49 virtual ~HTTPRequestHandler();
helmut 0:5150b09127e3 50
helmut 0:5150b09127e3 51 //protected:
helmut 0:5150b09127e3 52 virtual void doGet() = 0;
helmut 0:5150b09127e3 53 virtual void doPost() = 0;
helmut 0:5150b09127e3 54 virtual void doHead() = 0;
helmut 0:5150b09127e3 55
helmut 0:5150b09127e3 56 virtual void onReadable() = 0; //Data has been read
helmut 0:5150b09127e3 57 virtual void onWriteable() = 0; //Data has been written & buf is free
helmut 0:5150b09127e3 58 virtual void onTimeout(); //Connection has timed out
helmut 0:5150b09127e3 59 virtual void onClose() = 0; //Connection is closing
helmut 0:5150b09127e3 60
helmut 0:5150b09127e3 61 virtual void close(); //Close socket and destroy data
helmut 0:5150b09127e3 62
helmut 0:5150b09127e3 63 protected:
helmut 0:5150b09127e3 64 map<string, string>& reqHeaders() /*const*/;
helmut 0:5150b09127e3 65 string& path() /*const*/;
helmut 0:5150b09127e3 66 int dataLen() const;
helmut 0:5150b09127e3 67 int readData(char* buf, int len);
helmut 0:5150b09127e3 68 string& rootPath() /*const*/;
helmut 0:5150b09127e3 69
helmut 0:5150b09127e3 70 void setErrCode(int errc);
helmut 0:5150b09127e3 71 void setContentLen(int len);
helmut 0:5150b09127e3 72
helmut 0:5150b09127e3 73 map<string, string>& respHeaders();
helmut 0:5150b09127e3 74 int writeData(const char* buf, int len);
helmut 0:5150b09127e3 75
helmut 0:5150b09127e3 76 void setTimeout(int ms);
helmut 0:5150b09127e3 77 void resetTimeout();
helmut 0:5150b09127e3 78
helmut 0:5150b09127e3 79 private:
helmut 0:5150b09127e3 80 void readHeaders(); //Called at instanciation
helmut 0:5150b09127e3 81 void writeHeaders(); //Called at the first writeData call
helmut 0:5150b09127e3 82 void onTCPSocketEvent(TCPSocketEvent e);
helmut 0:5150b09127e3 83
helmut 0:5150b09127e3 84 TCPSocket* m_pTCPSocket;
helmut 0:5150b09127e3 85 map<string, string> m_reqHeaders;
helmut 0:5150b09127e3 86 map<string, string> m_respHeaders;
helmut 0:5150b09127e3 87 string m_rootPath;
helmut 0:5150b09127e3 88 string m_path;
helmut 0:5150b09127e3 89 int m_errc; //Response code
helmut 0:5150b09127e3 90
helmut 0:5150b09127e3 91 Timeout m_watchdog;
helmut 0:5150b09127e3 92 int m_timeout;
helmut 0:5150b09127e3 93
helmut 0:5150b09127e3 94 bool m_closed;
helmut 0:5150b09127e3 95 bool m_headersSent;
helmut 0:5150b09127e3 96
helmut 0:5150b09127e3 97 int readLine(char* str, int maxLen);
helmut 0:5150b09127e3 98
helmut 0:5150b09127e3 99 };
helmut 0:5150b09127e3 100
helmut 0:5150b09127e3 101 #endif