Nuvoton
/
NuMaker-mbed-tcp
NuMaker Ethernet TCP
Revision 19:43ee976c5259, committed 2020-09-01
- Comitter:
- cyliang
- Date:
- Tue Sep 01 05:15:44 2020 +0000
- Parent:
- 18:65dbb1786dc4
- Commit message:
- Support both of OS v5.15 and v6.2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 65dbb1786dc4 -r 43ee976c5259 main.cpp --- a/main.cpp Mon Dec 09 10:02:21 2019 +0000 +++ b/main.cpp Tue Sep 01 05:15:44 2020 +0000 @@ -21,11 +21,7 @@ const int HTTP_SERVER_PORT = 8080; #endif -#if defined(TARGET_VK_RZ_A1H) - const int RECV_BUFFER_SIZE = 300; -#else const int RECV_BUFFER_SIZE = 512; -#endif // Test related data const char *HTTP_OK_STR = "200 OK"; @@ -45,6 +41,9 @@ mbed_stats_heap_t heap_stats; #endif +#ifdef MBED_MAJOR_VERSION + printf("Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); +#endif printf("Start TCP test \r\n"); bool result = true; @@ -52,14 +51,26 @@ EthernetInterface eth; eth.connect(); //Use DHCP - + +#if (MBED_MAJOR_VERSION == 6) + static SocketAddress sa; + eth.get_ip_address(&sa); + printf("TCP client IP Address is %s\r\n", sa.get_ip_address()); + TCPSocket sock; + sock.open(ð); + + eth.gethostbyname(HTTP_SERVER_NAME, &sa); + sa.set_port(HTTP_SERVER_PORT); + if (sock.connect(sa) == 0) { + printf("HTTP: Connected to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT); +#else printf("TCP client IP Address is %s\r\n", eth.get_ip_address()); TCPSocket sock(ð); if (sock.connect(HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0) { printf("HTTP: Connected to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT); - +#endif // We are constructing GET command like this: #ifndef USE_HTTP_1_1 // GET http://www.ifconfig.io/method HTTP/1.0\n\n
diff -r 65dbb1786dc4 -r 43ee976c5259 mbed-os.lib --- a/mbed-os.lib Mon Dec 09 10:02:21 2019 +0000 +++ b/mbed-os.lib Tue Sep 01 05:15:44 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#b6e5a0a8afa34dec9dae8963778aebce0c82a54b +https://github.com/ARMmbed/mbed-os/#6a244d7adffc0e93872cfc880e539ee11bbc6002