Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WIZnetInterface WIZwiki-W7500-lecture mbed
Fork of WIZwiki-W7500-lecture by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 00004 int main() { 00005 00006 EthernetInterface eth; 00007 00008 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02}; 00009 eth.init(mac_addr, "192.168.0.180", "255.255.255.0", "192.168.0.1"); // USE Static IP 00010 //eth.init(mac_addr); //Use DHCP 00011 eth.connect(); 00012 00013 printf("IP Address is %s\r\n", eth.getIPAddress()); 00014 00015 TCPSocketConnection tcp_sock; 00016 tcp_sock.connect("192.168.0.244", 4545); 00017 char message[] = "Hello World!\r\n"; 00018 tcp_sock.send(message, sizeof(message)-1); 00019 char buffer[400]; 00020 int ret; 00021 while (true) 00022 { 00023 ret = tcp_sock.receive(buffer, sizeof(buffer)-1); 00024 if (ret > 0) 00025 { 00026 buffer[ret] = '\0'; 00027 printf("Received %d chars from server: %s\n", ret, buffer); 00028 } 00029 } 00030 00031 tcp_sock.close(); 00032 00033 eth.disconnect(); 00034 00035 printf("Disconnected!"); 00036 }
Generated on Tue Jul 12 2022 21:38:01 by
1.7.2
