TCP Echo Server Example using WizFi310
Dependencies: NetworkSocketAPI WizFi310Interface mbed
You are viewing an older revision! See the latest version
Homepage
Prerequisite¶
This example shows that Wizwiki-W7500 and WizFi310 operates as a TCP server.
When receiving data from a TCP client, it returns same data.
To implement this function, you need a Platform board and Wi-Fi board. Below are what we used.
- WIZwiki-W7500 from WIZnet (Platform board)
- WizFi310 from WIZnet (Wi-Fi board)
Hardware Configuration¶
WIZwiki-W7500 Pin map¶
WizFi310 Shield Pin map¶
Software¶
Connect to Wi-Fi
wifi.connect(AP_SSID, AP_PASSWORD, AP_SECURITY);
Get information
const char *ip = wifi.get_ip_address(); const char *mac = wifi.get_mac_address();
Receive data and return to TCP client
while (true) { int n = clt_sock.recv(buffer, sizeof(buffer)); if( n < 0 ) { clt_sock.close(); srv.close(); } if( n > 0 ) { buffer[n] = '\0'; printf("length : %d\r\n", n); clt_sock.send(buffer, n); } }
Caution¶
TCP client and server should be in a same network.