Philippe Bazot / Mbed 2 deprecated DU4SmartCities

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
icraggs
Date:
Wed Oct 01 13:27:35 2014 +0000
Revision:
8:80d49dd91542
Parent:
6:37b6d0d56190
Remove conditional compilation for IBM IoT settings

Who changed what in which revision?

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