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