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 UDPSocket udp_sock; 00016 udp_sock.init(); 00017 udp_sock.bind(60001); 00018 Endpoint udp_server; 00019 udp_server.set_address("192.168.0.244",4023); 00020 char message[] = "Hello World!!\r\n"; 00021 udp_sock.sendTo(udp_server,message,sizeof(message)-1); 00022 char buffer[400]; 00023 int ret; 00024 while (true) { 00025 ret = udp_sock.receiveFrom(udp_server, buffer, sizeof(buffer)-1); 00026 if (ret > 0){ 00027 buffer[ret] = '\0'; 00028 printf("Received %d chars from server: %s\n", ret, buffer); 00029 } 00030 } 00031 eth.disconnect(); 00032 00033 printf("Disconnected!"); 00034 }
Generated on Sat Jul 30 2022 18:01:24 by
1.7.2
