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 * fsm.h - Network Control Protocol Finite State Machine header file.
helmut 0:5150b09127e3 3 *
helmut 0:5150b09127e3 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
helmut 0:5150b09127e3 5 * Copyright (c) 1997 Global Election Systems Inc.
helmut 0:5150b09127e3 6 *
helmut 0:5150b09127e3 7 * The authors hereby grant permission to use, copy, modify, distribute,
helmut 0:5150b09127e3 8 * and license this software and its documentation for any purpose, provided
helmut 0:5150b09127e3 9 * that existing copyright notices are retained in all copies and that this
helmut 0:5150b09127e3 10 * notice and the following disclaimer are included verbatim in any
helmut 0:5150b09127e3 11 * distributions. No written agreement, license, or royalty fee is required
helmut 0:5150b09127e3 12 * for any of the authorized uses.
helmut 0:5150b09127e3 13 *
helmut 0:5150b09127e3 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
helmut 0:5150b09127e3 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
helmut 0:5150b09127e3 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
helmut 0:5150b09127e3 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
helmut 0:5150b09127e3 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
helmut 0:5150b09127e3 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
helmut 0:5150b09127e3 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
helmut 0:5150b09127e3 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
helmut 0:5150b09127e3 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
helmut 0:5150b09127e3 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
helmut 0:5150b09127e3 24 *
helmut 0:5150b09127e3 25 ******************************************************************************
helmut 0:5150b09127e3 26 * REVISION HISTORY
helmut 0:5150b09127e3 27 *
helmut 0:5150b09127e3 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
helmut 0:5150b09127e3 29 * Ported to lwIP.
helmut 0:5150b09127e3 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
helmut 0:5150b09127e3 31 * Original based on BSD code.
helmut 0:5150b09127e3 32 *****************************************************************************/
helmut 0:5150b09127e3 33 /*
helmut 0:5150b09127e3 34 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
helmut 0:5150b09127e3 35 *
helmut 0:5150b09127e3 36 * Copyright (c) 1989 Carnegie Mellon University.
helmut 0:5150b09127e3 37 * All rights reserved.
helmut 0:5150b09127e3 38 *
helmut 0:5150b09127e3 39 * Redistribution and use in source and binary forms are permitted
helmut 0:5150b09127e3 40 * provided that the above copyright notice and this paragraph are
helmut 0:5150b09127e3 41 * duplicated in all such forms and that any documentation,
helmut 0:5150b09127e3 42 * advertising materials, and other materials related to such
helmut 0:5150b09127e3 43 * distribution and use acknowledge that the software was developed
helmut 0:5150b09127e3 44 * by Carnegie Mellon University. The name of the
helmut 0:5150b09127e3 45 * University may not be used to endorse or promote products derived
helmut 0:5150b09127e3 46 * from this software without specific prior written permission.
helmut 0:5150b09127e3 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
helmut 0:5150b09127e3 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
helmut 0:5150b09127e3 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
helmut 0:5150b09127e3 50 *
helmut 0:5150b09127e3 51 * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $
helmut 0:5150b09127e3 52 */
helmut 0:5150b09127e3 53
helmut 0:5150b09127e3 54 #ifndef FSM_H
helmut 0:5150b09127e3 55 #define FSM_H
helmut 0:5150b09127e3 56
helmut 0:5150b09127e3 57 /*
helmut 0:5150b09127e3 58 * LCP Packet header = Code, id, length.
helmut 0:5150b09127e3 59 */
helmut 0:5150b09127e3 60 #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
helmut 0:5150b09127e3 61
helmut 0:5150b09127e3 62
helmut 0:5150b09127e3 63 /*
helmut 0:5150b09127e3 64 * CP (LCP, IPCP, etc.) codes.
helmut 0:5150b09127e3 65 */
helmut 0:5150b09127e3 66 #define CONFREQ 1 /* Configuration Request */
helmut 0:5150b09127e3 67 #define CONFACK 2 /* Configuration Ack */
helmut 0:5150b09127e3 68 #define CONFNAK 3 /* Configuration Nak */
helmut 0:5150b09127e3 69 #define CONFREJ 4 /* Configuration Reject */
helmut 0:5150b09127e3 70 #define TERMREQ 5 /* Termination Request */
helmut 0:5150b09127e3 71 #define TERMACK 6 /* Termination Ack */
helmut 0:5150b09127e3 72 #define CODEREJ 7 /* Code Reject */
helmut 0:5150b09127e3 73
helmut 0:5150b09127e3 74
helmut 0:5150b09127e3 75 /*
helmut 0:5150b09127e3 76 * Each FSM is described by an fsm structure and fsm callbacks.
helmut 0:5150b09127e3 77 */
helmut 0:5150b09127e3 78 typedef struct fsm {
helmut 0:5150b09127e3 79 int unit; /* Interface unit number */
helmut 0:5150b09127e3 80 u_short protocol; /* Data Link Layer Protocol field value */
helmut 0:5150b09127e3 81 int state; /* State */
helmut 0:5150b09127e3 82 int flags; /* Contains option bits */
helmut 0:5150b09127e3 83 u_char id; /* Current id */
helmut 0:5150b09127e3 84 u_char reqid; /* Current request id */
helmut 0:5150b09127e3 85 u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
helmut 0:5150b09127e3 86 int timeouttime; /* Timeout time in milliseconds */
helmut 0:5150b09127e3 87 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
helmut 0:5150b09127e3 88 int retransmits; /* Number of retransmissions left */
helmut 0:5150b09127e3 89 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
helmut 0:5150b09127e3 90 int nakloops; /* Number of nak loops since last ack */
helmut 0:5150b09127e3 91 int maxnakloops; /* Maximum number of nak loops tolerated */
helmut 0:5150b09127e3 92 struct fsm_callbacks* callbacks; /* Callback routines */
helmut 0:5150b09127e3 93 char* term_reason; /* Reason for closing protocol */
helmut 0:5150b09127e3 94 int term_reason_len; /* Length of term_reason */
helmut 0:5150b09127e3 95 } fsm;
helmut 0:5150b09127e3 96
helmut 0:5150b09127e3 97
helmut 0:5150b09127e3 98 typedef struct fsm_callbacks {
helmut 0:5150b09127e3 99 void (*resetci)(fsm*); /* Reset our Configuration Information */
helmut 0:5150b09127e3 100 int (*cilen)(fsm*); /* Length of our Configuration Information */
helmut 0:5150b09127e3 101 void (*addci)(fsm*, u_char*, int*); /* Add our Configuration Information */
helmut 0:5150b09127e3 102 int (*ackci)(fsm*, u_char*, int); /* ACK our Configuration Information */
helmut 0:5150b09127e3 103 int (*nakci)(fsm*, u_char*, int); /* NAK our Configuration Information */
helmut 0:5150b09127e3 104 int (*rejci)(fsm*, u_char*, int); /* Reject our Configuration Information */
helmut 0:5150b09127e3 105 int (*reqci)(fsm*, u_char*, int*, int); /* Request peer's Configuration Information */
helmut 0:5150b09127e3 106 void (*up)(fsm*); /* Called when fsm reaches LS_OPENED state */
helmut 0:5150b09127e3 107 void (*down)(fsm*); /* Called when fsm leaves LS_OPENED state */
helmut 0:5150b09127e3 108 void (*starting)(fsm*); /* Called when we want the lower layer */
helmut 0:5150b09127e3 109 void (*finished)(fsm*); /* Called when we don't want the lower layer */
helmut 0:5150b09127e3 110 void (*protreject)(int); /* Called when Protocol-Reject received */
helmut 0:5150b09127e3 111 void (*retransmit)(fsm*); /* Retransmission is necessary */
helmut 0:5150b09127e3 112 int (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */
helmut 0:5150b09127e3 113 char *proto_name; /* String name for protocol (for messages) */
helmut 0:5150b09127e3 114 } fsm_callbacks;
helmut 0:5150b09127e3 115
helmut 0:5150b09127e3 116
helmut 0:5150b09127e3 117 /*
helmut 0:5150b09127e3 118 * Link states.
helmut 0:5150b09127e3 119 */
helmut 0:5150b09127e3 120 #define LS_INITIAL 0 /* Down, hasn't been opened */
helmut 0:5150b09127e3 121 #define LS_STARTING 1 /* Down, been opened */
helmut 0:5150b09127e3 122 #define LS_CLOSED 2 /* Up, hasn't been opened */
helmut 0:5150b09127e3 123 #define LS_STOPPED 3 /* Open, waiting for down event */
helmut 0:5150b09127e3 124 #define LS_CLOSING 4 /* Terminating the connection, not open */
helmut 0:5150b09127e3 125 #define LS_STOPPING 5 /* Terminating, but open */
helmut 0:5150b09127e3 126 #define LS_REQSENT 6 /* We've sent a Config Request */
helmut 0:5150b09127e3 127 #define LS_ACKRCVD 7 /* We've received a Config Ack */
helmut 0:5150b09127e3 128 #define LS_ACKSENT 8 /* We've sent a Config Ack */
helmut 0:5150b09127e3 129 #define LS_OPENED 9 /* Connection available */
helmut 0:5150b09127e3 130
helmut 0:5150b09127e3 131 /*
helmut 0:5150b09127e3 132 * Flags - indicate options controlling FSM operation
helmut 0:5150b09127e3 133 */
helmut 0:5150b09127e3 134 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
helmut 0:5150b09127e3 135 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
helmut 0:5150b09127e3 136 #define OPT_SILENT 4 /* Wait for peer to speak first */
helmut 0:5150b09127e3 137
helmut 0:5150b09127e3 138
helmut 0:5150b09127e3 139 /*
helmut 0:5150b09127e3 140 * Prototypes
helmut 0:5150b09127e3 141 */
helmut 0:5150b09127e3 142 void fsm_init (fsm*);
helmut 0:5150b09127e3 143 void fsm_lowerup (fsm*);
helmut 0:5150b09127e3 144 void fsm_lowerdown (fsm*);
helmut 0:5150b09127e3 145 void fsm_open (fsm*);
helmut 0:5150b09127e3 146 void fsm_close (fsm*, char*);
helmut 0:5150b09127e3 147 void fsm_input (fsm*, u_char*, int);
helmut 0:5150b09127e3 148 void fsm_protreject (fsm*);
helmut 0:5150b09127e3 149 void fsm_sdata (fsm*, u_char, u_char, u_char*, int);
helmut 0:5150b09127e3 150
helmut 0:5150b09127e3 151
helmut 0:5150b09127e3 152 /*
helmut 0:5150b09127e3 153 * Variables
helmut 0:5150b09127e3 154 */
helmut 0:5150b09127e3 155 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
helmut 0:5150b09127e3 156
helmut 0:5150b09127e3 157 #endif /* FSM_H */