testing of combination of LCS and LAN

Dependencies:   mbed

Committer:
damir
Date:
Wed Jan 14 13:29:55 2015 +0000
Revision:
0:a7a6a692162f
Test of LAN

Who changed what in which revision?

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