save loops

Dependencies:   mbed

Committer:
mbedalvaro
Date:
Tue Dec 02 08:29:59 2014 +0000
Revision:
1:3be7b7d050f4
Parent:
0:df6fdd9b99f0
updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 0:df6fdd9b99f0 1
mbedalvaro 0:df6fdd9b99f0 2 /*
mbedalvaro 0:df6fdd9b99f0 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mbedalvaro 0:df6fdd9b99f0 4
mbedalvaro 0:df6fdd9b99f0 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mbedalvaro 0:df6fdd9b99f0 6 of this software and associated documentation files (the "Software"), to deal
mbedalvaro 0:df6fdd9b99f0 7 in the Software without restriction, including without limitation the rights
mbedalvaro 0:df6fdd9b99f0 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbedalvaro 0:df6fdd9b99f0 9 copies of the Software, and to permit persons to whom the Software is
mbedalvaro 0:df6fdd9b99f0 10 furnished to do so, subject to the following conditions:
mbedalvaro 0:df6fdd9b99f0 11
mbedalvaro 0:df6fdd9b99f0 12 The above copyright notice and this permission notice shall be included in
mbedalvaro 0:df6fdd9b99f0 13 all copies or substantial portions of the Software.
mbedalvaro 0:df6fdd9b99f0 14
mbedalvaro 0:df6fdd9b99f0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbedalvaro 0:df6fdd9b99f0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbedalvaro 0:df6fdd9b99f0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbedalvaro 0:df6fdd9b99f0 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbedalvaro 0:df6fdd9b99f0 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbedalvaro 0:df6fdd9b99f0 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mbedalvaro 0:df6fdd9b99f0 21 THE SOFTWARE.
mbedalvaro 0:df6fdd9b99f0 22 */
mbedalvaro 0:df6fdd9b99f0 23
mbedalvaro 0:df6fdd9b99f0 24 /** \file
mbedalvaro 0:df6fdd9b99f0 25 Ethernet network interface header file
mbedalvaro 0:df6fdd9b99f0 26 */
mbedalvaro 0:df6fdd9b99f0 27
mbedalvaro 0:df6fdd9b99f0 28 #ifndef ETHERNETNETIF_H
mbedalvaro 0:df6fdd9b99f0 29 #define ETHERNETNETIF_H
mbedalvaro 0:df6fdd9b99f0 30
mbedalvaro 0:df6fdd9b99f0 31 struct netif;
mbedalvaro 0:df6fdd9b99f0 32
mbedalvaro 0:df6fdd9b99f0 33 #include "mbed.h"
mbedalvaro 0:df6fdd9b99f0 34
mbedalvaro 0:df6fdd9b99f0 35 #include "if/lwip/LwipNetIf.h"
mbedalvaro 0:df6fdd9b99f0 36
mbedalvaro 0:df6fdd9b99f0 37 ///Ethernet network interface return codes
mbedalvaro 0:df6fdd9b99f0 38 enum EthernetErr
mbedalvaro 0:df6fdd9b99f0 39 {
mbedalvaro 0:df6fdd9b99f0 40 __ETH_MIN = -0xFFFF,
mbedalvaro 0:df6fdd9b99f0 41 ETH_TIMEOUT, ///<Timeout during setup
mbedalvaro 0:df6fdd9b99f0 42 ETH_OK = 0 ///<Success
mbedalvaro 0:df6fdd9b99f0 43 };
mbedalvaro 0:df6fdd9b99f0 44
mbedalvaro 0:df6fdd9b99f0 45 ///Ethernet network interface
mbedalvaro 0:df6fdd9b99f0 46 /**
mbedalvaro 0:df6fdd9b99f0 47 This class provides Ethernet connectivity to the stack
mbedalvaro 0:df6fdd9b99f0 48 */
mbedalvaro 0:df6fdd9b99f0 49 class EthernetNetIf : public LwipNetIf
mbedalvaro 0:df6fdd9b99f0 50 {
mbedalvaro 0:df6fdd9b99f0 51 public:
mbedalvaro 0:df6fdd9b99f0 52 ///Instantiates the Interface and register it against the stack, DHCP will be used
mbedalvaro 0:df6fdd9b99f0 53 EthernetNetIf(); //W/ DHCP
mbedalvaro 0:df6fdd9b99f0 54
mbedalvaro 0:df6fdd9b99f0 55 ///Instantiates the Interface and register it against the stack, DHCP will not be used
mbedalvaro 0:df6fdd9b99f0 56 /**
mbedalvaro 0:df6fdd9b99f0 57 IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
mbedalvaro 0:df6fdd9b99f0 58 */
mbedalvaro 0:df6fdd9b99f0 59 EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
mbedalvaro 0:df6fdd9b99f0 60 virtual ~EthernetNetIf();
mbedalvaro 0:df6fdd9b99f0 61
mbedalvaro 0:df6fdd9b99f0 62 ///Brings the interface up
mbedalvaro 0:df6fdd9b99f0 63 /**
mbedalvaro 0:df6fdd9b99f0 64 Uses DHCP if necessary
mbedalvaro 0:df6fdd9b99f0 65 @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
mbedalvaro 0:df6fdd9b99f0 66 @return : ETH_OK on success or ETH_TIMEOUT on timeout
mbedalvaro 0:df6fdd9b99f0 67 */
mbedalvaro 0:df6fdd9b99f0 68 EthernetErr setup(int timeout_ms = 15000);
mbedalvaro 0:df6fdd9b99f0 69
mbedalvaro 0:df6fdd9b99f0 70 virtual void poll();
mbedalvaro 0:df6fdd9b99f0 71
mbedalvaro 0:df6fdd9b99f0 72 private:
mbedalvaro 0:df6fdd9b99f0 73 Timer m_ethArpTimer;
mbedalvaro 0:df6fdd9b99f0 74 Timer m_dhcpCoarseTimer;
mbedalvaro 0:df6fdd9b99f0 75 Timer m_dhcpFineTimer;
mbedalvaro 0:df6fdd9b99f0 76 Timer m_igmpTimer;
mbedalvaro 0:df6fdd9b99f0 77
mbedalvaro 0:df6fdd9b99f0 78 bool m_useDhcp;
mbedalvaro 0:df6fdd9b99f0 79
mbedalvaro 0:df6fdd9b99f0 80 netif* m_pNetIf;
mbedalvaro 0:df6fdd9b99f0 81
mbedalvaro 0:df6fdd9b99f0 82 IpAddr m_netmask;
mbedalvaro 0:df6fdd9b99f0 83 IpAddr m_gateway;
mbedalvaro 0:df6fdd9b99f0 84
mbedalvaro 0:df6fdd9b99f0 85 const char* m_hostname;
mbedalvaro 0:df6fdd9b99f0 86
mbedalvaro 0:df6fdd9b99f0 87 };
mbedalvaro 0:df6fdd9b99f0 88
mbedalvaro 0:df6fdd9b99f0 89 #endif
mbedalvaro 0:df6fdd9b99f0 90