![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Non-blocking example of the LWIPInterface
Dependencies: LWIPInterface NetworkSocketAPI mbed-rtos mbed
Non-blocking example for the NetworkSocketAPI. Attempts to get the device's public facing IP address from ifcfg.me using the Happy Eyeballs algorithm to fetch an IPv4 or IPv6 address.
Diff: main.cpp
- Revision:
- 50:a9926b8b21fe
- Parent:
- 46:cf5ab96729e1
- Child:
- 57:fb2f8e188383
--- a/main.cpp Wed Mar 02 17:22:10 2016 +0000 +++ b/main.cpp Wed Mar 09 06:04:19 2016 +0000 @@ -19,7 +19,10 @@ #include "TCPSocket.h" DigitalOut myled(LED_GREEN); -void flash(){ myled = !myled; } +void flash() +{ + myled = !myled; +} LWIPInterface eth; TCPSocket socket(ð); @@ -31,7 +34,7 @@ printf("NetworkSocketAPI Example\r\n"); eth.connect(); - + const char *ip = eth.getIPAddress(); const char *mac = eth.getMACAddress(); printf("IP Address is: %s\r\n", (ip) ? ip : "No IP"); @@ -48,6 +51,6 @@ eth.disconnect(); printf("Recieved: %ld bytes, %02x%02x%02x%02x\r\n", size, - recieved[0], recieved[1], recieved[2], recieved[3]); + recieved[0], recieved[1], recieved[2], recieved[3]); printf("NetworkSocketAPI Example Finished\r\n"); }