W5500 driver for mbed OS 5

Dependents:   http-webserver-example mbed-os-example-sockets

Fork of W5500Interface by Sergei G

Committer:
Bongjun
Date:
Thu Aug 09 08:10:27 2018 +0000
Revision:
6:e2ab76b2be07
Child:
9:351e20cf7d05
changes for mbed OS 5 web server example; - add internal W5500 instance; - changes for web server example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bongjun 6:e2ab76b2be07 1 // DHCPClient.h 2013/4/10
Bongjun 6:e2ab76b2be07 2 #ifndef DHCPCLIENT_H
Bongjun 6:e2ab76b2be07 3 #define DHCPCLIENT_H
Bongjun 6:e2ab76b2be07 4 #include "wiznet.h"
Bongjun 6:e2ab76b2be07 5 #include "UDPSocket.h"
Bongjun 6:e2ab76b2be07 6
Bongjun 6:e2ab76b2be07 7 #define DHCP_OFFSET_OP 0
Bongjun 6:e2ab76b2be07 8 #define DHCP_OFFSET_XID 4
Bongjun 6:e2ab76b2be07 9 #define DHCP_OFFSET_YIADDR 16
Bongjun 6:e2ab76b2be07 10 #define DHCP_OFFSET_SIADDR 20
Bongjun 6:e2ab76b2be07 11 #define DHCP_OFFSET_OPTIONS 240
Bongjun 6:e2ab76b2be07 12 #define DHCP_MAX_PACKET_SIZE 600
Bongjun 6:e2ab76b2be07 13
Bongjun 6:e2ab76b2be07 14 // DHCP Message Type
Bongjun 6:e2ab76b2be07 15 #define DHCPDISCOVER 1
Bongjun 6:e2ab76b2be07 16 #define DHCPOFFER 2
Bongjun 6:e2ab76b2be07 17 #define DHCPREQUEST 3
Bongjun 6:e2ab76b2be07 18 #define DHCPDECLINE 4
Bongjun 6:e2ab76b2be07 19 #define DHCPACK 5
Bongjun 6:e2ab76b2be07 20 #define DHCPNAK 6
Bongjun 6:e2ab76b2be07 21 #define DHCPRELEASE 7
Bongjun 6:e2ab76b2be07 22 #define DHCPINFORM 8
Bongjun 6:e2ab76b2be07 23
Bongjun 6:e2ab76b2be07 24 class DHCPClient {
Bongjun 6:e2ab76b2be07 25 public:
Bongjun 6:e2ab76b2be07 26 DHCPClient();
Bongjun 6:e2ab76b2be07 27 int setup(NetworkStack *ns, uint8_t mac_addr[6], int timeout_ms = 15*1000);
Bongjun 6:e2ab76b2be07 28 uint8_t chaddr[6]; // MAC
Bongjun 6:e2ab76b2be07 29 uint8_t yiaddr[4]; // IP
Bongjun 6:e2ab76b2be07 30 uint8_t dnsaddr[4]; // DNS
Bongjun 6:e2ab76b2be07 31 uint8_t gateway[4];
Bongjun 6:e2ab76b2be07 32 uint8_t netmask[4];
Bongjun 6:e2ab76b2be07 33 uint8_t siaddr[4];
Bongjun 6:e2ab76b2be07 34 private:
Bongjun 6:e2ab76b2be07 35 int discover();
Bongjun 6:e2ab76b2be07 36 int request();
Bongjun 6:e2ab76b2be07 37 int offer(uint8_t buf[], int size);
Bongjun 6:e2ab76b2be07 38 void add_buf(uint8_t* buf, int len);
Bongjun 6:e2ab76b2be07 39 void fill_buf(int len, uint8_t data = 0x00);
Bongjun 6:e2ab76b2be07 40 void add_buf(uint8_t c);
Bongjun 6:e2ab76b2be07 41 void add_option(uint8_t code, uint8_t* buf = NULL, int len = 0);
Bongjun 6:e2ab76b2be07 42 bool verify(uint8_t buf[], int len);
Bongjun 6:e2ab76b2be07 43 void callback();
Bongjun 6:e2ab76b2be07 44 UDPSocket* m_udp;
Bongjun 6:e2ab76b2be07 45 SocketAddress m_server;
Bongjun 6:e2ab76b2be07 46 uint8_t xid[4];
Bongjun 6:e2ab76b2be07 47 bool exit_flag;
Bongjun 6:e2ab76b2be07 48 Timer m_interval;
Bongjun 6:e2ab76b2be07 49 int m_retry;
Bongjun 6:e2ab76b2be07 50 uint8_t m_buf[DHCP_MAX_PACKET_SIZE];
Bongjun 6:e2ab76b2be07 51 int m_pos;
Bongjun 6:e2ab76b2be07 52 //WIZnet_Chip* eth;
Bongjun 6:e2ab76b2be07 53 };
Bongjun 6:e2ab76b2be07 54 #endif //DHCPCLIENT_H