adds getMACAddress() like getIPAddress(). Initializes in constructor.
Dependencies: Socket lwip-eth lwip-sys lwip
Dependents: EtherTest2 SmartLight
Fork of EthernetInterface by
EthernetInterface.h@26:132037eec2ba, 2012-09-01 (annotated)
- Committer:
- jonathonfletcher
- Date:
- Sat Sep 01 11:15:56 2012 +0000
- Revision:
- 26:132037eec2ba
- Parent:
- 24:c9bb345dcc65
add getMACAddress() in the style of getIPAddress(). Initialize the MAC string from the constructor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 3:f5776537f27f | 1 | /* EthernetInterface.h */ |
donatien | 3:f5776537f27f | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
donatien | 3:f5776537f27f | 3 | * |
donatien | 3:f5776537f27f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
donatien | 3:f5776537f27f | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
donatien | 3:f5776537f27f | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
donatien | 3:f5776537f27f | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
donatien | 3:f5776537f27f | 8 | * furnished to do so, subject to the following conditions: |
donatien | 3:f5776537f27f | 9 | * |
donatien | 3:f5776537f27f | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
donatien | 3:f5776537f27f | 11 | * substantial portions of the Software. |
donatien | 3:f5776537f27f | 12 | * |
donatien | 3:f5776537f27f | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
donatien | 3:f5776537f27f | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
donatien | 3:f5776537f27f | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
donatien | 3:f5776537f27f | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 3:f5776537f27f | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
donatien | 3:f5776537f27f | 18 | */ |
jonathonfletcher | 26:132037eec2ba | 19 | |
donatien | 3:f5776537f27f | 20 | #ifndef ETHERNETINTERFACE_H_ |
donatien | 3:f5776537f27f | 21 | #define ETHERNETINTERFACE_H_ |
donatien | 3:f5776537f27f | 22 | |
emilmont | 23:5d5b40c4378b | 23 | #if !defined(TARGET_LPC1768) |
emilmont | 23:5d5b40c4378b | 24 | #error The Ethernet Interface library is supported only on the mbed NXP LPC1768 |
emilmont | 23:5d5b40c4378b | 25 | #endif |
emilmont | 23:5d5b40c4378b | 26 | |
donatien | 3:f5776537f27f | 27 | #include "rtos.h" |
donatien | 3:f5776537f27f | 28 | #include "lwip/netif.h" |
donatien | 3:f5776537f27f | 29 | |
jonathonfletcher | 26:132037eec2ba | 30 | /** Interface using Ethernet to connect to an IP-based network |
jonathonfletcher | 26:132037eec2ba | 31 | * |
jonathonfletcher | 26:132037eec2ba | 32 | */ |
jonathonfletcher | 26:132037eec2ba | 33 | class EthernetInterface |
jonathonfletcher | 26:132037eec2ba | 34 | { |
donatien | 3:f5776537f27f | 35 | public: |
jonathonfletcher | 26:132037eec2ba | 36 | |
jonathonfletcher | 26:132037eec2ba | 37 | /* |
jonathonfletcher | 26:132037eec2ba | 38 | * Constructor |
jonathonfletcher | 26:132037eec2ba | 39 | */ |
jonathonfletcher | 26:132037eec2ba | 40 | EthernetInterface(); |
jonathonfletcher | 26:132037eec2ba | 41 | |
jonathonfletcher | 26:132037eec2ba | 42 | /** Initialize the interface with DHCP. |
jonathonfletcher | 26:132037eec2ba | 43 | * Initialize the interface and configure it to use DHCP (no connection at this point). |
jonathonfletcher | 26:132037eec2ba | 44 | * \return 0 on success, a negative number on failure |
jonathonfletcher | 26:132037eec2ba | 45 | */ |
jonathonfletcher | 26:132037eec2ba | 46 | static int init(); //With DHCP |
donatien | 3:f5776537f27f | 47 | |
jonathonfletcher | 26:132037eec2ba | 48 | /** Initialize the interface with a static IP address. |
jonathonfletcher | 26:132037eec2ba | 49 | * Initialize the interface and configure it with the following static configuration (no connection at this point). |
jonathonfletcher | 26:132037eec2ba | 50 | * \param ip the IP address to use |
jonathonfletcher | 26:132037eec2ba | 51 | * \param mask the IP address mask |
jonathonfletcher | 26:132037eec2ba | 52 | * \param gateway the gateway to use |
jonathonfletcher | 26:132037eec2ba | 53 | * \return 0 on success, a negative number on failure |
jonathonfletcher | 26:132037eec2ba | 54 | */ |
jonathonfletcher | 26:132037eec2ba | 55 | static int init(const char* ip, const char* mask, const char* gateway); |
donatien | 3:f5776537f27f | 56 | |
jonathonfletcher | 26:132037eec2ba | 57 | /** Connect |
jonathonfletcher | 26:132037eec2ba | 58 | * Bring the interface up, start DHCP if needed. |
jonathonfletcher | 26:132037eec2ba | 59 | * \param timeout_ms timeout in ms (default: (12)s). |
jonathonfletcher | 26:132037eec2ba | 60 | * \return 0 on success, a negative number on failure |
jonathonfletcher | 26:132037eec2ba | 61 | */ |
jonathonfletcher | 26:132037eec2ba | 62 | static int connect(unsigned int timeout_ms=12000); |
jonathonfletcher | 26:132037eec2ba | 63 | |
jonathonfletcher | 26:132037eec2ba | 64 | /** Disconnect |
jonathonfletcher | 26:132037eec2ba | 65 | * Bring the interface down |
jonathonfletcher | 26:132037eec2ba | 66 | * \return 0 on success, a negative number on failure |
jonathonfletcher | 26:132037eec2ba | 67 | */ |
jonathonfletcher | 26:132037eec2ba | 68 | static int disconnect(); |
jonathonfletcher | 26:132037eec2ba | 69 | |
jonathonfletcher | 26:132037eec2ba | 70 | static char* getIPAddress(); |
jonathonfletcher | 26:132037eec2ba | 71 | |
jonathonfletcher | 26:132037eec2ba | 72 | static char* getMACAddress(); |
donatien | 3:f5776537f27f | 73 | }; |
donatien | 3:f5776537f27f | 74 | |
emilmont | 15:fd9597f1b81b | 75 | #include "TCPSocketConnection.h" |
emilmont | 15:fd9597f1b81b | 76 | #include "TCPSocketServer.h" |
emilmont | 17:b7a3766f6253 | 77 | |
emilmont | 20:0d9ae7845bfe | 78 | #include "Endpoint.h" |
donatien | 3:f5776537f27f | 79 | #include "UDPSocket.h" |
donatien | 3:f5776537f27f | 80 | |
donatien | 3:f5776537f27f | 81 | #endif /* ETHERNETINTERFACE_H_ */ |