NNN50 WIFI_API library

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

This is mbed compatible EthernetInterface lib exclude for Delta DFCM-NNN50 platform.

Additional information and examples can be found in mbed Handbook

Committer:
tsungta
Date:
Wed Nov 23 17:36:49 2016 +0000
Revision:
0:06fccc63b33d
20:7c3d78d; alpha release for NNN50; SoftAP mode is not yet supported.

Who changed what in which revision?

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