W5500 driver for mbed OS 5
Dependents: http-webserver-example mbed-os-example-sockets
Fork of W5500Interface by
Revision 17:60f75e78f35d, committed 2018-08-14
- Comitter:
- Bongjun
- Date:
- Tue Aug 14 01:20:36 2018 +0000
- Parent:
- 16:380b4a629c4f
- Child:
- 18:afec30f0922a
- Commit message:
- remove dhcp codes in W5500.c/.h; remove gethostbyname() in W5500.c/.h; remove printfBytes(), printHex(), debug_hex() in W5500.c/.h
Changed in this revision
--- a/W5500Interface.cpp Tue Aug 14 01:02:27 2018 +0000 +++ b/W5500Interface.cpp Tue Aug 14 01:20:36 2018 +0000 @@ -91,6 +91,22 @@ //_daemon->start(callback(this, &W5500Interface::daemon)); } +uint32_t W5500Interface:: str_to_ip(const char* str) +{ + uint32_t ip = 0; + char* p = (char*)str; + for(int i = 0; i < 4; i++) { + ip |= atoi(p); + p = strchr(p, '.'); + if (p == NULL) { + break; + } + ip <<= 8; + p++; + } + return ip; +} + int W5500Interface::init() { _dhcp_enable = true;
--- a/W5500Interface.h Tue Aug 14 01:02:27 2018 +0000 +++ b/W5500Interface.h Tue Aug 14 01:20:36 2018 +0000 @@ -131,6 +131,7 @@ SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC); int IPrenew(int timeout_ms = 15*1000); + uint32_t str_to_ip(const char* str); protected: /** Opens a socket
--- a/WIZnet/W5500.cpp Tue Aug 14 01:02:27 2018 +0000 +++ b/WIZnet/W5500.cpp Tue Aug 14 01:20:36 2018 +0000 @@ -41,7 +41,6 @@ cs = 1; reset_pin = 1; inst = this; - dhcp = false; } /* @@ -52,7 +51,6 @@ cs = 1; reset_pin = 1; inst = this; - dhcp = false; } */ @@ -116,25 +114,6 @@ return true; } -bool WIZnet_Chip::gethostbyname(const char* host, uint32_t* ip) -{ -#if 0 - uint32_t addr = str_to_ip(host); - char buf[17]; - snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff); - if (strcmp(buf, host) == 0) { - *ip = addr; - return true; - } - DNSClient client; - if(client.lookup(host)) { - *ip = client.ip; - return true; - } -#endif - return false; -} - bool WIZnet_Chip::disconnect() { return true; @@ -401,23 +380,7 @@ #endif spi->unlock(); } - -uint32_t str_to_ip(const char* str) -{ - uint32_t ip = 0; - char* p = (char*)str; - for(int i = 0; i < 4; i++) { - ip |= atoi(p); - p = strchr(p, '.'); - if (p == NULL) { - break; - } - ip <<= 8; - p++; - } - return ip; -} - +/* void printfBytes(char* str, uint8_t* buf, int len) { printf("%s %d:", str, len); @@ -454,5 +417,5 @@ } debug("\n"); } - +*/ #endif
--- a/WIZnet/W5500.h Tue Aug 14 01:02:27 2018 +0000 +++ b/WIZnet/W5500.h Tue Aug 14 01:20:36 2018 +0000 @@ -174,17 +174,6 @@ int recv(int socket, char* buf, int len); - /* - * Return true if the module is using dhcp - * - * @returns true if the module is using dhcp - */ - bool isDHCP() { - return dhcp; - } - - bool gethostbyname(const char* host, uint32_t* ip); - static WIZnet_Chip * getInstance() { return inst; }; @@ -280,7 +269,9 @@ DigitalOut reset_pin; }; +/* extern uint32_t str_to_ip(const char* str); extern void printfBytes(char* str, uint8_t* buf, int len); extern void printHex(uint8_t* buf, int len); extern void debug_hex(uint8_t* buf, int len); +*/ \ No newline at end of file