This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
vipinranka
Date:
Wed Jan 11 11:41:30 2017 +0000
Revision:
12:9a20164dcc47
This is the final version MGAS Project for Renesas GR Peach Design Contest

Who changed what in which revision?

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