ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:39:15 2014 +0000
Revision:
2:14b689a85306
Parent:
0:7766f6712673
bug fix

Who changed what in which revision?

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