Temperature monitoring with thingspeak

Dependencies:   Socket lwip-eth lwip-sys lwip

Dependents:   HTTPClientexample

Committer:
MohamadNazrin
Date:
Mon Feb 12 07:10:08 2018 +0000
Revision:
0:3b4a8d2e1539
nothing changes on ethernetInterface

Who changed what in which revision?

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