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