For lecture
Dependencies: WIZnetInterface WIZwiki-W7500-lecture mbed
Fork of WIZwiki-W7500-lecture2-udp by
Revision 4:e802635c137f, committed 2016-02-01
- Comitter:
- bangbh
- Date:
- Mon Feb 01 03:38:51 2016 +0000
- Parent:
- 3:f549134aa6c4
- Child:
- 5:5ac02e0a1296
- Commit message:
- For lecture DNS
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Feb 01 01:23:21 2016 +0000
+++ b/main.cpp Mon Feb 01 03:38:51 2016 +0000
@@ -1,4 +1,5 @@
#include "mbed.h"
+#include "DNSClient.h"
#include "EthernetInterface.h"
int main() {
@@ -6,28 +7,16 @@
EthernetInterface eth;
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
- eth.init(mac_addr, "192.168.0.180", "255.255.255.0", "192.168.0.1"); // USE Static IP
+ eth.init(mac_addr, "222.98.173.239", "255.255.255.192", "222.98.173.254"); // USE Static IP
//eth.init(mac_addr); //Use DHCP
eth.connect();
printf("IP Address is %s\r\n", eth.getIPAddress());
-
- UDPSocket udp_sock;
- udp_sock.init();
- udp_sock.bind(60001);
- Endpoint udp_server;
- udp_server.set_address("192.168.0.244",4023);
- char message[] = "Hello World!!\r\n";
- udp_sock.sendTo(udp_server,message,sizeof(message)-1);
- char buffer[400];
- int ret;
- while (true) {
- ret = udp_sock.receiveFrom(udp_server, buffer, sizeof(buffer)-1);
- if (ret > 0){
- buffer[ret] = '\0';
- printf("Received %d chars from server: %s\n", ret, buffer);
- }
- }
+
+ DNSClient client;
+
+ client.lookup("openweathermap.org");
+ printf("http://openweathermap.org/ ip address: %d.%d.%d.%d\r\n",(client.ip&0xff000000)>>24,(client.ip&0x00ff0000)>>16,(client.ip&0x0000ff00)>>8,(client.ip&0x000000ff)>>0);
eth.disconnect();
printf("Disconnected!");
