This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500, W5200 and W5100. One of them can be selected by enabling it in wiznet.h.
Fork of WIZnet_Library by
Diff: WIZnetInterface/DHCPClient/DHCPClient.cpp
- Revision:
- 9:f390679a0468
- Parent:
- 0:b72d22e10709
--- a/WIZnetInterface/DHCPClient/DHCPClient.cpp Sun May 31 10:25:40 2015 +0000 +++ b/WIZnetInterface/DHCPClient/DHCPClient.cpp Mon Jun 04 14:31:13 2018 +0000 @@ -7,8 +7,9 @@ #define DBG_DHCP 0 #if DBG_DHCP -#define DBG(...) do{debug("[%s:%d]", __PRETTY_FUNCTION__,__LINE__);debug(__VA_ARGS__);} while(0); -#define DBG_HEX(A,B) do{debug("[%s:%d]\r\n", __PRETTY_FUNCTION__,__LINE__);debug_hex(A,B);} while(0); +extern Serial pc; +#define DBG(...) do{pc.printf("[%s:%d]", __PRETTY_FUNCTION__,__LINE__);pc.printf(__VA_ARGS__);} while(0); +#define DBG_HEX(A,B) do{pc.printf("[%s:%d]\r\n", __PRETTY_FUNCTION__,__LINE__);pc.printf("%x %x\r\n",A,B);} while(0); #else #define DBG(...) while(0); #define DBG_HEX(A,B) while(0); @@ -19,7 +20,7 @@ m_pos = 0; const uint8_t header[] = {0x01,0x01,0x06,0x00}; add_buf((uint8_t*)header, sizeof(header)); - uint32_t x = time(NULL) + rand(); + uint32_t x = rand(); xid[0] = x>>24; xid[1] = x>>16; xid[2] = x>>8; xid[3] = x; add_buf(xid, 4); fill_buf(20, 0x00); @@ -112,6 +113,7 @@ { Endpoint host; int recv_len = m_udp->receiveFrom(host, (char*)m_buf, sizeof(m_buf)); + DBG("%d\r\n",recv_len); if (recv_len < 0) { return; } @@ -168,7 +170,7 @@ } m_udp = new UDPSocket; m_udp->init(); - m_udp->set_blocking(false); + m_udp->set_blocking(false,5000); eth->reg_wr<uint32_t>(SIPR, 0x00000000); // local ip "0.0.0.0" m_udp->bind(68); // local port m_server.set_address("255.255.255.255", 67); // DHCP broadcast @@ -184,7 +186,9 @@ break; case 1: send_size = discover(); + DBG("sendTo\r\n"); m_udp->sendTo(m_server, (char*)m_buf, send_size); + DBG("after sendTo\r\n"); m_interval.reset(); m_interval.start(); seq++;