ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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