Revised to prevent DHCPClient::discover from hanging.
Fork of WIZ820ioInterface by
Revision 9:c1722862c13b, committed 2014-08-15
- Comitter:
- rraab
- Date:
- Fri Aug 15 19:53:25 2014 +0000
- Parent:
- 8:6ff41cd782f5
- Commit message:
- Fixed DHCPClient::discover calling rand, which hangs in an infinite loop.
Changed in this revision
--- a/DHCPClient/DHCPClient.cpp Tue Feb 04 03:20:06 2014 +0000 +++ b/DHCPClient/DHCPClient.cpp Fri Aug 15 19:53:25 2014 +0000 @@ -19,7 +19,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 = time(NULL) + 0x8042;//rand(); xid[0] = x>>24; xid[1] = x>>16; xid[2] = x>>8; xid[3] = x; add_buf(xid, 4); fill_buf(20, 0x00);
--- a/WIZ820io/WIZ820io.cpp Tue Feb 04 03:20:06 2014 +0000 +++ b/WIZ820io/WIZ820io.cpp Fri Aug 15 19:53:25 2014 +0000 @@ -22,7 +22,7 @@ #include "DNSClient.h" //Debug is disabled by default -#if 0 +#if 1 #define DBG(...) do{debug("%p %d %s ", this,__LINE__,__PRETTY_FUNCTION__); debug(__VA_ARGS__); } while(0); //#define DBG(x, ...) debug("[WIZ820io:DBG]"x"\r\n", ##__VA_ARGS__); #define WARN(x, ...) debug("[WIZ820io:WARN]"x"\r\n", ##__VA_ARGS__); @@ -39,7 +39,7 @@ #define INFO(x, ...) #endif -#define DBG_SPI 0 +#define DBG_SPI 1 WIZ820io* WIZ820io::inst; @@ -143,9 +143,10 @@ #ifdef TARGET_LPC1114 uint8_t mac[6] = {0x00,0x02,0xf7,0xf0,0x00,0x00}; #else - uint8_t mac[6]; - mbed_mac_address((char*)mac); + uint8_t mac[6] = {0x00,0x02,0xf7,0xf0,0x00,0x00}; + //mbed_mac_address((char*)mac); #endif + printf("Writing MAC...\r\n"); reg_wr_mac(SHAR, mac); }
--- a/WIZ820ioInterface.cpp Tue Feb 04 03:20:06 2014 +0000 +++ b/WIZ820ioInterface.cpp Fri Aug 15 19:53:25 2014 +0000 @@ -82,11 +82,11 @@ int WIZ820ioInterface::IPrenew(int timeout_ms) { -// printf("DHCP Started, waiting for IP...\n"); + printf("DHCP Started, waiting for IP...\n"); DHCPClient dhcp; int err = dhcp.setup(timeout_ms); if (err == (-1)) { -// printf("Timeout.\n"); + printf("Timeout.\n"); return -1; } // printf("Connected, IP: %d.%d.%d.%d\n", dhcp.yiaddr[0], dhcp.yiaddr[1], dhcp.yiaddr[2], dhcp.yiaddr[3]);