Marco Hsu / WIFI_API_32kRAM
Committer:
Marcomissyou
Date:
Fri Jun 26 09:44:35 2015 +0000
Revision:
0:4085cc9441f3
Commit WIFI_API_32kRAM; This API works on DFCM-NNN40-DT1R(32K RAM).

Who changed what in which revision?

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