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 /** @file
helmut 0:5150b09127e3 2 */
helmut 0:5150b09127e3 3
helmut 0:5150b09127e3 4 #ifndef __LWIP_DHCP_H__
helmut 0:5150b09127e3 5 #define __LWIP_DHCP_H__
helmut 0:5150b09127e3 6
helmut 0:5150b09127e3 7 #include "lwip/opt.h"
helmut 0:5150b09127e3 8
helmut 0:5150b09127e3 9 #if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */
helmut 0:5150b09127e3 10
helmut 0:5150b09127e3 11 #include "lwip/netif.h"
helmut 0:5150b09127e3 12 #include "lwip/udp.h"
helmut 0:5150b09127e3 13
helmut 0:5150b09127e3 14 #ifdef __cplusplus
helmut 0:5150b09127e3 15 extern "C" {
helmut 0:5150b09127e3 16 #endif
helmut 0:5150b09127e3 17
helmut 0:5150b09127e3 18 /** period (in seconds) of the application calling dhcp_coarse_tmr() */
helmut 0:5150b09127e3 19 #define DHCP_COARSE_TIMER_SECS 60
helmut 0:5150b09127e3 20 /** period (in milliseconds) of the application calling dhcp_coarse_tmr() */
helmut 0:5150b09127e3 21 #define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL)
helmut 0:5150b09127e3 22 /** period (in milliseconds) of the application calling dhcp_fine_tmr() */
helmut 0:5150b09127e3 23 #define DHCP_FINE_TIMER_MSECS 500
helmut 0:5150b09127e3 24
helmut 0:5150b09127e3 25 #define DHCP_CHADDR_LEN 16U
helmut 0:5150b09127e3 26 #define DHCP_SNAME_LEN 64U
helmut 0:5150b09127e3 27 #define DHCP_FILE_LEN 128U
helmut 0:5150b09127e3 28
helmut 0:5150b09127e3 29 struct dhcp
helmut 0:5150b09127e3 30 {
helmut 0:5150b09127e3 31 /** transaction identifier of last sent request */
helmut 0:5150b09127e3 32 u32_t xid;
helmut 0:5150b09127e3 33 /** our connection to the DHCP server */
helmut 0:5150b09127e3 34 struct udp_pcb *pcb;
helmut 0:5150b09127e3 35 /** incoming msg */
helmut 0:5150b09127e3 36 struct dhcp_msg *msg_in;
helmut 0:5150b09127e3 37 /** current DHCP state machine state */
helmut 0:5150b09127e3 38 u8_t state;
helmut 0:5150b09127e3 39 /** retries of current request */
helmut 0:5150b09127e3 40 u8_t tries;
helmut 0:5150b09127e3 41 #if LWIP_DHCP_AUTOIP_COOP
helmut 0:5150b09127e3 42 u8_t autoip_coop_state;
helmut 0:5150b09127e3 43 #endif
helmut 0:5150b09127e3 44 u8_t subnet_mask_given;
helmut 0:5150b09127e3 45
helmut 0:5150b09127e3 46 struct pbuf *p_out; /* pbuf of outcoming msg */
helmut 0:5150b09127e3 47 struct dhcp_msg *msg_out; /* outgoing msg */
helmut 0:5150b09127e3 48 u16_t options_out_len; /* outgoing msg options length */
helmut 0:5150b09127e3 49 u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
helmut 0:5150b09127e3 50 u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
helmut 0:5150b09127e3 51 u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
helmut 0:5150b09127e3 52 ip_addr_t server_ip_addr; /* dhcp server address that offered this lease */
helmut 0:5150b09127e3 53 ip_addr_t offered_ip_addr;
helmut 0:5150b09127e3 54 ip_addr_t offered_sn_mask;
helmut 0:5150b09127e3 55 ip_addr_t offered_gw_addr;
helmut 0:5150b09127e3 56
helmut 0:5150b09127e3 57 u32_t offered_t0_lease; /* lease period (in seconds) */
helmut 0:5150b09127e3 58 u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
helmut 0:5150b09127e3 59 u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */
helmut 0:5150b09127e3 60 /* @todo: LWIP_DHCP_BOOTP_FILE configuration option?
helmut 0:5150b09127e3 61 integrate with possible TFTP-client for booting? */
helmut 0:5150b09127e3 62 #if LWIP_DHCP_BOOTP_FILE
helmut 0:5150b09127e3 63 ip_addr_t offered_si_addr;
helmut 0:5150b09127e3 64 char boot_file_name[DHCP_FILE_LEN];
helmut 0:5150b09127e3 65 #endif /* LWIP_DHCP_BOOTPFILE */
helmut 0:5150b09127e3 66 };
helmut 0:5150b09127e3 67
helmut 0:5150b09127e3 68 /* MUST be compiled with "pack structs" or equivalent! */
helmut 0:5150b09127e3 69 #ifdef PACK_STRUCT_USE_INCLUDES
helmut 0:5150b09127e3 70 # include "arch/bpstruct.h"
helmut 0:5150b09127e3 71 #endif
helmut 0:5150b09127e3 72 PACK_STRUCT_BEGIN
helmut 0:5150b09127e3 73 /** minimum set of fields of any DHCP message */
helmut 0:5150b09127e3 74 struct dhcp_msg
helmut 0:5150b09127e3 75 {
helmut 0:5150b09127e3 76 PACK_STRUCT_FIELD(u8_t op);
helmut 0:5150b09127e3 77 PACK_STRUCT_FIELD(u8_t htype);
helmut 0:5150b09127e3 78 PACK_STRUCT_FIELD(u8_t hlen);
helmut 0:5150b09127e3 79 PACK_STRUCT_FIELD(u8_t hops);
helmut 0:5150b09127e3 80 PACK_STRUCT_FIELD(u32_t xid);
helmut 0:5150b09127e3 81 PACK_STRUCT_FIELD(u16_t secs);
helmut 0:5150b09127e3 82 PACK_STRUCT_FIELD(u16_t flags);
helmut 0:5150b09127e3 83 PACK_STRUCT_FIELD(ip_addr_p_t ciaddr);
helmut 0:5150b09127e3 84 PACK_STRUCT_FIELD(ip_addr_p_t yiaddr);
helmut 0:5150b09127e3 85 PACK_STRUCT_FIELD(ip_addr_p_t siaddr);
helmut 0:5150b09127e3 86 PACK_STRUCT_FIELD(ip_addr_p_t giaddr);
helmut 0:5150b09127e3 87 PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
helmut 0:5150b09127e3 88 PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
helmut 0:5150b09127e3 89 PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
helmut 0:5150b09127e3 90 PACK_STRUCT_FIELD(u32_t cookie);
helmut 0:5150b09127e3 91 #define DHCP_MIN_OPTIONS_LEN 68U
helmut 0:5150b09127e3 92 /** make sure user does not configure this too small */
helmut 0:5150b09127e3 93 #if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
helmut 0:5150b09127e3 94 # undef DHCP_OPTIONS_LEN
helmut 0:5150b09127e3 95 #endif
helmut 0:5150b09127e3 96 /** allow this to be configured in lwipopts.h, but not too small */
helmut 0:5150b09127e3 97 #if (!defined(DHCP_OPTIONS_LEN))
helmut 0:5150b09127e3 98 /** set this to be sufficient for your options in outgoing DHCP msgs */
helmut 0:5150b09127e3 99 # define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
helmut 0:5150b09127e3 100 #endif
helmut 0:5150b09127e3 101 PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]);
helmut 0:5150b09127e3 102 } PACK_STRUCT_STRUCT;
helmut 0:5150b09127e3 103 PACK_STRUCT_END
helmut 0:5150b09127e3 104 #ifdef PACK_STRUCT_USE_INCLUDES
helmut 0:5150b09127e3 105 # include "arch/epstruct.h"
helmut 0:5150b09127e3 106 #endif
helmut 0:5150b09127e3 107
helmut 0:5150b09127e3 108 void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp);
helmut 0:5150b09127e3 109 /** start DHCP configuration */
helmut 0:5150b09127e3 110 err_t dhcp_start(struct netif *netif);
helmut 0:5150b09127e3 111 /** enforce early lease renewal (not needed normally)*/
helmut 0:5150b09127e3 112 err_t dhcp_renew(struct netif *netif);
helmut 0:5150b09127e3 113 /** release the DHCP lease, usually called before dhcp_stop()*/
helmut 0:5150b09127e3 114 err_t dhcp_release(struct netif *netif);
helmut 0:5150b09127e3 115 /** stop DHCP configuration */
helmut 0:5150b09127e3 116 void dhcp_stop(struct netif *netif);
helmut 0:5150b09127e3 117 /** inform server of our manual IP address */
helmut 0:5150b09127e3 118 void dhcp_inform(struct netif *netif);
helmut 0:5150b09127e3 119 /** Handle a possible change in the network configuration */
helmut 0:5150b09127e3 120 void dhcp_network_changed(struct netif *netif);
helmut 0:5150b09127e3 121
helmut 0:5150b09127e3 122 /** if enabled, check whether the offered IP address is not in use, using ARP */
helmut 0:5150b09127e3 123 #if DHCP_DOES_ARP_CHECK
helmut 0:5150b09127e3 124 void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr);
helmut 0:5150b09127e3 125 #endif
helmut 0:5150b09127e3 126
helmut 0:5150b09127e3 127 /** to be called every minute */
helmut 0:5150b09127e3 128 void dhcp_coarse_tmr(void);
helmut 0:5150b09127e3 129 /** to be called every half second */
helmut 0:5150b09127e3 130 void dhcp_fine_tmr(void);
helmut 0:5150b09127e3 131
helmut 0:5150b09127e3 132 /** DHCP message item offsets and length */
helmut 0:5150b09127e3 133 #define DHCP_OP_OFS 0
helmut 0:5150b09127e3 134 #define DHCP_HTYPE_OFS 1
helmut 0:5150b09127e3 135 #define DHCP_HLEN_OFS 2
helmut 0:5150b09127e3 136 #define DHCP_HOPS_OFS 3
helmut 0:5150b09127e3 137 #define DHCP_XID_OFS 4
helmut 0:5150b09127e3 138 #define DHCP_SECS_OFS 8
helmut 0:5150b09127e3 139 #define DHCP_FLAGS_OFS 10
helmut 0:5150b09127e3 140 #define DHCP_CIADDR_OFS 12
helmut 0:5150b09127e3 141 #define DHCP_YIADDR_OFS 16
helmut 0:5150b09127e3 142 #define DHCP_SIADDR_OFS 20
helmut 0:5150b09127e3 143 #define DHCP_GIADDR_OFS 24
helmut 0:5150b09127e3 144 #define DHCP_CHADDR_OFS 28
helmut 0:5150b09127e3 145 #define DHCP_SNAME_OFS 44
helmut 0:5150b09127e3 146 #define DHCP_FILE_OFS 108
helmut 0:5150b09127e3 147 #define DHCP_MSG_LEN 236
helmut 0:5150b09127e3 148
helmut 0:5150b09127e3 149 #define DHCP_COOKIE_OFS DHCP_MSG_LEN
helmut 0:5150b09127e3 150 #define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4)
helmut 0:5150b09127e3 151
helmut 0:5150b09127e3 152 #define DHCP_CLIENT_PORT 68
helmut 0:5150b09127e3 153 #define DHCP_SERVER_PORT 67
helmut 0:5150b09127e3 154
helmut 0:5150b09127e3 155 /** DHCP client states */
helmut 0:5150b09127e3 156 #define DHCP_OFF 0
helmut 0:5150b09127e3 157 #define DHCP_REQUESTING 1
helmut 0:5150b09127e3 158 #define DHCP_INIT 2
helmut 0:5150b09127e3 159 #define DHCP_REBOOTING 3
helmut 0:5150b09127e3 160 #define DHCP_REBINDING 4
helmut 0:5150b09127e3 161 #define DHCP_RENEWING 5
helmut 0:5150b09127e3 162 #define DHCP_SELECTING 6
helmut 0:5150b09127e3 163 #define DHCP_INFORMING 7
helmut 0:5150b09127e3 164 #define DHCP_CHECKING 8
helmut 0:5150b09127e3 165 #define DHCP_PERMANENT 9
helmut 0:5150b09127e3 166 #define DHCP_BOUND 10
helmut 0:5150b09127e3 167 /** not yet implemented #define DHCP_RELEASING 11 */
helmut 0:5150b09127e3 168 #define DHCP_BACKING_OFF 12
helmut 0:5150b09127e3 169
helmut 0:5150b09127e3 170 /** AUTOIP cooperatation flags */
helmut 0:5150b09127e3 171 #define DHCP_AUTOIP_COOP_STATE_OFF 0
helmut 0:5150b09127e3 172 #define DHCP_AUTOIP_COOP_STATE_ON 1
helmut 0:5150b09127e3 173
helmut 0:5150b09127e3 174 #define DHCP_BOOTREQUEST 1
helmut 0:5150b09127e3 175 #define DHCP_BOOTREPLY 2
helmut 0:5150b09127e3 176
helmut 0:5150b09127e3 177 /** DHCP message types */
helmut 0:5150b09127e3 178 #define DHCP_DISCOVER 1
helmut 0:5150b09127e3 179 #define DHCP_OFFER 2
helmut 0:5150b09127e3 180 #define DHCP_REQUEST 3
helmut 0:5150b09127e3 181 #define DHCP_DECLINE 4
helmut 0:5150b09127e3 182 #define DHCP_ACK 5
helmut 0:5150b09127e3 183 #define DHCP_NAK 6
helmut 0:5150b09127e3 184 #define DHCP_RELEASE 7
helmut 0:5150b09127e3 185 #define DHCP_INFORM 8
helmut 0:5150b09127e3 186
helmut 0:5150b09127e3 187 /** DHCP hardware type, currently only ethernet is supported */
helmut 0:5150b09127e3 188 #define DHCP_HTYPE_ETH 1
helmut 0:5150b09127e3 189
helmut 0:5150b09127e3 190 #define DHCP_MAGIC_COOKIE 0x63825363UL
helmut 0:5150b09127e3 191
helmut 0:5150b09127e3 192 /* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */
helmut 0:5150b09127e3 193
helmut 0:5150b09127e3 194 /** BootP options */
helmut 0:5150b09127e3 195 #define DHCP_OPTION_PAD 0
helmut 0:5150b09127e3 196 #define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
helmut 0:5150b09127e3 197 #define DHCP_OPTION_ROUTER 3
helmut 0:5150b09127e3 198 #define DHCP_OPTION_DNS_SERVER 6
helmut 0:5150b09127e3 199 #define DHCP_OPTION_HOSTNAME 12
helmut 0:5150b09127e3 200 #define DHCP_OPTION_IP_TTL 23
helmut 0:5150b09127e3 201 #define DHCP_OPTION_MTU 26
helmut 0:5150b09127e3 202 #define DHCP_OPTION_BROADCAST 28
helmut 0:5150b09127e3 203 #define DHCP_OPTION_TCP_TTL 37
helmut 0:5150b09127e3 204 #define DHCP_OPTION_END 255
helmut 0:5150b09127e3 205
helmut 0:5150b09127e3 206 /** DHCP options */
helmut 0:5150b09127e3 207 #define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
helmut 0:5150b09127e3 208 #define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
helmut 0:5150b09127e3 209 #define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
helmut 0:5150b09127e3 210
helmut 0:5150b09127e3 211 #define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
helmut 0:5150b09127e3 212 #define DHCP_OPTION_MESSAGE_TYPE_LEN 1
helmut 0:5150b09127e3 213
helmut 0:5150b09127e3 214 #define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
helmut 0:5150b09127e3 215 #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
helmut 0:5150b09127e3 216
helmut 0:5150b09127e3 217 #define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
helmut 0:5150b09127e3 218 #define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
helmut 0:5150b09127e3 219
helmut 0:5150b09127e3 220 #define DHCP_OPTION_T1 58 /* T1 renewal time */
helmut 0:5150b09127e3 221 #define DHCP_OPTION_T2 59 /* T2 rebinding time */
helmut 0:5150b09127e3 222 #define DHCP_OPTION_US 60
helmut 0:5150b09127e3 223 #define DHCP_OPTION_CLIENT_ID 61
helmut 0:5150b09127e3 224 #define DHCP_OPTION_TFTP_SERVERNAME 66
helmut 0:5150b09127e3 225 #define DHCP_OPTION_BOOTFILE 67
helmut 0:5150b09127e3 226
helmut 0:5150b09127e3 227 /** possible combinations of overloading the file and sname fields with options */
helmut 0:5150b09127e3 228 #define DHCP_OVERLOAD_NONE 0
helmut 0:5150b09127e3 229 #define DHCP_OVERLOAD_FILE 1
helmut 0:5150b09127e3 230 #define DHCP_OVERLOAD_SNAME 2
helmut 0:5150b09127e3 231 #define DHCP_OVERLOAD_SNAME_FILE 3
helmut 0:5150b09127e3 232
helmut 0:5150b09127e3 233 #ifdef __cplusplus
helmut 0:5150b09127e3 234 }
helmut 0:5150b09127e3 235 #endif
helmut 0:5150b09127e3 236
helmut 0:5150b09127e3 237 #endif /* LWIP_DHCP */
helmut 0:5150b09127e3 238
helmut 0:5150b09127e3 239 #endif /*__LWIP_DHCP_H__*/