fdsf

Dependents:   sisk_proj_stat MQTT Hello_FXOS8700Q WireFSHandControl ... more

Committer:
grzemich
Date:
Wed Dec 07 23:47:50 2016 +0000
Revision:
0:d7bd7384a37c
dgd

Who changed what in which revision?

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