Fork of original library, increased Tx buffer to 16kB

Dependents:   W5500-SNTPClient-example

Committer:
star297
Date:
Thu May 02 20:47:25 2019 +0000
Revision:
0:e9275bdfa393
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
star297 0:e9275bdfa393 1 // EthernetInterface for W5500 2014/8/20
star297 0:e9275bdfa393 2
star297 0:e9275bdfa393 3 #pragma once
star297 0:e9275bdfa393 4 #include "wiznet.h"
star297 0:e9275bdfa393 5
star297 0:e9275bdfa393 6 /** Interface using Wiznet W5500 chip to connect to an IP-based network
star297 0:e9275bdfa393 7 *
star297 0:e9275bdfa393 8 */
star297 0:e9275bdfa393 9
star297 0:e9275bdfa393 10
star297 0:e9275bdfa393 11 class EthernetInterface: public WIZnet_Chip {
star297 0:e9275bdfa393 12 public:
star297 0:e9275bdfa393 13
star297 0:e9275bdfa393 14 /**
star297 0:e9275bdfa393 15 * Constructor
star297 0:e9275bdfa393 16 *
star297 0:e9275bdfa393 17 * \param mosi mbed pin to use for SPI
star297 0:e9275bdfa393 18 * \param miso mbed pin to use for SPI
star297 0:e9275bdfa393 19 * \param sclk mbed pin to use for SPI
star297 0:e9275bdfa393 20 * \param cs chip select of the WIZnet_Chip
star297 0:e9275bdfa393 21 * \param reset reset pin of the WIZnet_Chip
star297 0:e9275bdfa393 22 */
star297 0:e9275bdfa393 23 EthernetInterface(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset);
star297 0:e9275bdfa393 24 EthernetInterface(SPI* spi, PinName cs, PinName reset);
star297 0:e9275bdfa393 25
star297 0:e9275bdfa393 26 /** Initialize the interface with DHCP w/o MAC address
star297 0:e9275bdfa393 27 * Initialize the interface and configure it to use DHCP (no connection at this point).
star297 0:e9275bdfa393 28 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 29 */
star297 0:e9275bdfa393 30 int init(); //With DHCP
star297 0:e9275bdfa393 31 /** Initialize the interface with DHCP.
star297 0:e9275bdfa393 32 * Initialize the interface and configure it to use DHCP (no connection at this point).
star297 0:e9275bdfa393 33 * \param mac the MAC address to use
star297 0:e9275bdfa393 34 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 35 */
star297 0:e9275bdfa393 36 int init(uint8_t * mac); //With DHCP
star297 0:e9275bdfa393 37
star297 0:e9275bdfa393 38 /** Initialize the interface with a static IP address without MAC.
star297 0:e9275bdfa393 39 * Initialize the interface and configure it with the following static configuration (no connection at this point).
star297 0:e9275bdfa393 40 * \param ip the IP address to use
star297 0:e9275bdfa393 41 * \param mask the IP address mask
star297 0:e9275bdfa393 42 * \param gateway the gateway to use
star297 0:e9275bdfa393 43 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 44 */
star297 0:e9275bdfa393 45
star297 0:e9275bdfa393 46 int init(const char* ip, const char* mask, const char* gateway);
star297 0:e9275bdfa393 47 /** Initialize the interface with a static IP address.
star297 0:e9275bdfa393 48 * Initialize the interface and configure it with the following static configuration (no connection at this point).
star297 0:e9275bdfa393 49 * \param mac the MAC address to use
star297 0:e9275bdfa393 50 * \param ip the IP address to use
star297 0:e9275bdfa393 51 * \param mask the IP address mask
star297 0:e9275bdfa393 52 * \param gateway the gateway to use
star297 0:e9275bdfa393 53 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 54 */
star297 0:e9275bdfa393 55 int init(uint8_t * mac, const char* ip, const char* mask, const char* gateway);
star297 0:e9275bdfa393 56
star297 0:e9275bdfa393 57 /** Connect
star297 0:e9275bdfa393 58 * Bring the interface up, start DHCP if needed.
star297 0:e9275bdfa393 59 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 60 */
star297 0:e9275bdfa393 61 int connect();
star297 0:e9275bdfa393 62
star297 0:e9275bdfa393 63 /** Disconnect
star297 0:e9275bdfa393 64 * Bring the interface down
star297 0:e9275bdfa393 65 * \return 0 on success, a negative number on failure
star297 0:e9275bdfa393 66 */
star297 0:e9275bdfa393 67 int disconnect();
star297 0:e9275bdfa393 68
star297 0:e9275bdfa393 69 /** Get IP address
star297 0:e9275bdfa393 70 *
star297 0:e9275bdfa393 71 * @ returns ip address
star297 0:e9275bdfa393 72 */
star297 0:e9275bdfa393 73 char* getIPAddress();
star297 0:e9275bdfa393 74 char* getNetworkMask();
star297 0:e9275bdfa393 75 char* getGateway();
star297 0:e9275bdfa393 76 char* getMACAddress();
star297 0:e9275bdfa393 77
star297 0:e9275bdfa393 78 int IPrenew(int timeout_ms = 15*1000);
star297 0:e9275bdfa393 79
star297 0:e9275bdfa393 80 private:
star297 0:e9275bdfa393 81 char ip_string[17];
star297 0:e9275bdfa393 82 char mask_string[17];
star297 0:e9275bdfa393 83 char gw_string[17];
star297 0:e9275bdfa393 84 char mac_string[20];
star297 0:e9275bdfa393 85 bool ip_set;
star297 0:e9275bdfa393 86 void getip(void);
star297 0:e9275bdfa393 87 };
star297 0:e9275bdfa393 88
star297 0:e9275bdfa393 89 #include "TCPSocketConnection.h"
star297 0:e9275bdfa393 90 #include "TCPSocketServer.h"
star297 0:e9275bdfa393 91 #include "UDPSocket.h"