Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
aziz111
Date:
Fri Mar 08 17:15:02 2019 +0000
Revision:
5:569a4894abc1
Parent:
3:78f223d34f36
Final

Who changed what in which revision?

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