Delta / NNN50_WIFI_API

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EthernetInterface.h Source File

EthernetInterface.h

00001 /* EthernetInterface.h */
00002 /* Copyright (C) 2012 mbed.org, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019  
00020 #ifndef ETHERNETINTERFACE_H_
00021 #define ETHERNETINTERFACE_H_
00022 
00023 /*Tsungta
00024 #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)
00025 #error The Ethernet Interface library is not supported on this target
00026 #endif
00027 
00028 #include "rtos.h"
00029 #include "lwip/netif.h"
00030 */
00031 
00032  /** Interface using Ethernet to connect to an IP-based network
00033  *
00034  */
00035 class EthernetInterface {
00036 public:
00037   /** Initialize the interface with DHCP.
00038   * Initialize the interface and configure it to use DHCP (no connection at this point).
00039   * \return 0 on success, a negative number on failure
00040   */
00041   static int init(); //With DHCP
00042 
00043   /** Initialize the interface with a static IP address.
00044   * Initialize the interface and configure it with the following static configuration (no connection at this point).
00045   * \param ip the IP address to use
00046   * \param mask the IP address mask
00047   * \param gateway the gateway to use
00048   * \return 0 on success, a negative number on failure
00049   */
00050   static int init(const char* ip, const char* mask, const char* gateway);
00051 
00052   /** Connect
00053   * Bring the interface up, start DHCP if needed.
00054   * \param   timeout_ms  timeout in ms (default: 5s).
00055   * \return 0 on success, a negative number on failure
00056   */
00057   static int connect(unsigned int timeout_ms=5000);
00058   
00059   /** Disconnect
00060   * Bring the interface down
00061   * \return 0 on success, a negative number on failure
00062   */
00063   static int disconnect();
00064   
00065   /** Get the MAC address of your Ethernet interface
00066    * \return a pointer to a string containing the MAC address
00067    */
00068   static char* getMACAddress();
00069   
00070   /** Get the IP address of your Ethernet interface
00071    * \return a pointer to a string containing the IP address
00072    */
00073   static char* getIPAddress();
00074 
00075   /** Get the Gateway address of your Ethernet interface
00076    * \return a pointer to a string containing the Gateway address
00077    */
00078   static char* getGateway();
00079 
00080   /** Get the Network mask of your Ethernet interface
00081    * \return a pointer to a string containing the Network mask
00082    */
00083   static char* getNetworkMask();
00084 };
00085 
00086 #include "TCPSocketConnection.h"
00087 #include "TCPSocketServer.h"
00088 
00089 #include "Endpoint.h"
00090 #include "UDPSocket.h"
00091 
00092 // following are added by Tsungta
00093 typedef struct ip_addr ip_addr_t;
00094 struct ip_addr {
00095   uint32_t addr;
00096 };
00097 //Tsungta
00098 
00099 #endif /* ETHERNETINTERFACE_H_ */
00100