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 #ifndef LWIPNETTCPSOCKET_H
helmut 0:5150b09127e3 25 #define LWIPNETTCPSOCKET_H
helmut 0:5150b09127e3 26
helmut 0:5150b09127e3 27 #define NET_LWIP_STACK 1
helmut 0:5150b09127e3 28 #include "if/net/nettcpsocket.h"
helmut 0:5150b09127e3 29 #include "LwipNetIf.h"
helmut 0:5150b09127e3 30
helmut 0:5150b09127e3 31 #include "stdint.h"
helmut 0:5150b09127e3 32
helmut 0:5150b09127e3 33 //Implements NetTcpSockets over lwIP raw API
helmut 0:5150b09127e3 34
helmut 0:5150b09127e3 35 struct tcp_pcb; //Represents a Tcp Connection, "Protocol Control Block", see rawapi.txt & tcp.h
helmut 0:5150b09127e3 36 struct pbuf; //Lwip Buffer Container
helmut 0:5150b09127e3 37
helmut 0:5150b09127e3 38 typedef signed char err_t;
helmut 0:5150b09127e3 39 typedef uint16_t u16_t;
helmut 0:5150b09127e3 40
helmut 0:5150b09127e3 41 class LwipNetTcpSocket: public NetTcpSocket
helmut 0:5150b09127e3 42 {
helmut 0:5150b09127e3 43 public:
helmut 0:5150b09127e3 44 LwipNetTcpSocket(tcp_pcb* pPcb = NULL); //Passes a pcb if already created (by an accept req for instance), in that case transfers ownership
helmut 0:5150b09127e3 45 virtual ~LwipNetTcpSocket();
helmut 0:5150b09127e3 46
helmut 0:5150b09127e3 47 virtual NetTcpSocketErr bind(const Host& me);
helmut 0:5150b09127e3 48 virtual NetTcpSocketErr listen();
helmut 0:5150b09127e3 49 virtual NetTcpSocketErr connect(const Host& host);
helmut 0:5150b09127e3 50 virtual NetTcpSocketErr accept(Host* pClient, NetTcpSocket** ppNewNetTcpSocket);
helmut 0:5150b09127e3 51
helmut 0:5150b09127e3 52 virtual int /*if < 0 : NetTcpSocketErr*/ send(const char* buf, int len);
helmut 0:5150b09127e3 53 virtual int /*if < 0 : NetTcpSocketErr*/ recv(char* buf, int len);
helmut 0:5150b09127e3 54
helmut 0:5150b09127e3 55 virtual NetTcpSocketErr close();
helmut 0:5150b09127e3 56
helmut 0:5150b09127e3 57 virtual NetTcpSocketErr poll();
helmut 0:5150b09127e3 58
helmut 0:5150b09127e3 59 protected:
helmut 0:5150b09127e3 60 volatile tcp_pcb* m_pPcb;
helmut 0:5150b09127e3 61
helmut 0:5150b09127e3 62 //Events callbacks from lwIp
helmut 0:5150b09127e3 63 err_t acceptCb(tcp_pcb* newpcb, err_t err);
helmut 0:5150b09127e3 64 err_t connectedCb(tcp_pcb* tpcb, err_t err);
helmut 0:5150b09127e3 65
helmut 0:5150b09127e3 66 void errCb(err_t err);
helmut 0:5150b09127e3 67
helmut 0:5150b09127e3 68 err_t sentCb(tcp_pcb* tpcb, u16_t len);
helmut 0:5150b09127e3 69 err_t recvCb(tcp_pcb* tpcb, pbuf *p, err_t err);
helmut 0:5150b09127e3 70
helmut 0:5150b09127e3 71 private:
helmut 0:5150b09127e3 72 void cleanUp(); //Flush input buffer
helmut 0:5150b09127e3 73
helmut 0:5150b09127e3 74 // queue<tcp_pcb*> m_lpInPcb; //Incoming connections that have not been accepted yet
helmut 0:5150b09127e3 75 queue<LwipNetTcpSocket*> m_lpInNetTcpSocket; //Incoming connections that have not been accepted yet
helmut 0:5150b09127e3 76
helmut 0:5150b09127e3 77 volatile pbuf* m_pReadPbuf; //Ptr to read buffer
helmut 0:5150b09127e3 78
helmut 0:5150b09127e3 79 //Static callbacks : Transforms into a C++ callback
helmut 0:5150b09127e3 80 static err_t sAcceptCb(void *arg, struct tcp_pcb *newpcb, err_t err);
helmut 0:5150b09127e3 81 static err_t sConnectedCb(void *arg, struct tcp_pcb *tpcb, err_t err);
helmut 0:5150b09127e3 82
helmut 0:5150b09127e3 83 static void sErrCb(void *arg, err_t err);
helmut 0:5150b09127e3 84
helmut 0:5150b09127e3 85 static err_t sSentCb(void *arg, struct tcp_pcb *tpcb, u16_t len);
helmut 0:5150b09127e3 86 static err_t sRecvCb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
helmut 0:5150b09127e3 87
helmut 0:5150b09127e3 88 };
helmut 0:5150b09127e3 89
helmut 0:5150b09127e3 90 #endif