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