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:
Mon Sep 04 05:40:11 2017 +0000
Revision:
32:8298a2fb074f
Parent:
22:5b38592bc0e6
56:f4cc53f; Add getRSSI() to readout RSSI while connected with AP router; Add SSL support refer to TCPSocketConnection.connect()

Who changed what in which revision?

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