No more update~~ please use W5500Interface.

Fork of EthernetInterfaceW5500 by Bongjun Hur

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EthernetInterfaceW5500.h Source File

EthernetInterfaceW5500.h

00001 // EthernetInterfaceW5500.h 2014/7/17
00002 
00003 #pragma once
00004 #include "wiznet.h"
00005 
00006  /** Interface using Wiznet chip to connect to an IP-based network
00007  *
00008  */
00009 class EthernetInterfaceW5500: public WIZnet_Chip {
00010 public:
00011 
00012     /**
00013     * Constructor
00014     *
00015     * \param mosi mbed pin to use for SPI
00016     * \param miso mbed pin to use for SPI
00017     * \param sclk mbed pin to use for SPI
00018     * \param cs chip select of the WIZnet_Chip
00019     * \param reset reset pin of the WIZnet_Chip
00020     */
00021     EthernetInterfaceW5500(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset);
00022     EthernetInterfaceW5500(SPI* spi, PinName cs, PinName reset);
00023 
00024   /** Initialize the interface with DHCP w/o MAC address
00025   * Initialize the interface and configure it to use DHCP (no connection at this point).
00026   * \return 0 on success, a negative number on failure
00027   */
00028   int init(); //With DHCP
00029   /** Initialize the interface with DHCP.
00030   * Initialize the interface and configure it to use DHCP (no connection at this point).
00031   * \param mac the MAC address to use
00032   * \return 0 on success, a negative number on failure
00033   */
00034   int init(uint8_t * mac); //With DHCP
00035 
00036   /** Initialize the interface with a static IP address without MAC.
00037   * Initialize the interface and configure it with the following static configuration (no connection at this point).
00038   * \param ip the IP address to use
00039   * \param mask the IP address mask
00040   * \param gateway the gateway to use
00041   * \return 0 on success, a negative number on failure
00042   */
00043 
00044   int init(const char* ip, const char* mask, const char* gateway);
00045   /** Initialize the interface with a static IP address.
00046   * Initialize the interface and configure it with the following static configuration (no connection at this point).
00047   * \param mac the MAC address to use
00048   * \param ip the IP address to use
00049   * \param mask the IP address mask
00050   * \param gateway the gateway to use
00051   * \return 0 on success, a negative number on failure
00052   */
00053   int init(uint8_t * mac, const char* ip, const char* mask, const char* gateway);
00054 
00055   /** Connect
00056   * Bring the interface up, start DHCP if needed.
00057   * \return 0 on success, a negative number on failure
00058   */
00059   int connect();
00060   
00061   /** Disconnect
00062   * Bring the interface down
00063   * \return 0 on success, a negative number on failure
00064   */
00065   int disconnect();
00066   
00067   /** Get IP address
00068   *
00069   * @ returns ip address
00070   */
00071   char* getIPAddress();
00072   char* getNetworkMask();
00073   char* getGateway();
00074   char* getMACAddress();
00075 
00076   int IPrenew(int timeout_ms = 15*1000);
00077     
00078 private:
00079     char ip_string[20];
00080     char mask_string[20];
00081     char gw_string[20];
00082     char mac_string[20];
00083     bool ip_set;
00084 };
00085 
00086 #include "TCPSocketConnection.h"
00087 #include "TCPSocketServer.h"
00088 #include "UDPSocket.h"