MyLibrary123

Fork of WizFi310Interface_Legacy by WIZnet

Revision:
2:ee7e278fe372
Parent:
1:e08ea0ee2788
--- a/WizFi310Interface.cpp	Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310Interface.cpp	Sun Sep 17 05:30:43 2017 +0000
@@ -64,6 +64,8 @@
 	return cmdWLEAVE();
 }
 
+
+
 char* WizFi310Interface::getMACAddress()
 {
     return _state.mac;
@@ -83,5 +85,45 @@
 {
 	return cmdWANT(mode);
 }
+//int WizFi310Interface::test()
+//{
+//	return cmdWSTATUS();
+//}
 
+
+int WizFi310Interface::test_weathermap()
+{   
+	// TCPSocketConnection();
+   int errConnect;
+    char http_cmd1[1000] = "";
+    char buffer[2048] = "";
+	TCPSocketConnection TCPconnection;
+
+   char *p="api.openweathermap.org";
+   int a=TCPconnection.connect(p,80);
+  while (true) {
+        if(a!=0) {
+            printf("\r\ncould not connect to socket : error = %d\r\n", p);
+            a = TCPconnection.connect(p, 80);
+        } else {
+            printf("socket connected\r\n");
+            break;
+        }
+    }    
+     char http_cmd[] = "GET /data/2.5/weather?q=Seoul,kr&appid=a0ca47dd7f6066404629b3e1ad728981 HTTP/1.0\n\n";
+          //char http_cmd[] = "GET /data/2.5/weather?q=London,us&appid=a0ca47dd7f6066404629b3e1ad728981 HTTP/1.0\n\n";
+        //char http_cmd[] = "GET /data/2.5/weather?q=Berlin,de&appid=a0ca47dd7f6066404629b3e1ad728981 HTTP/1.0\n\n";
+     
+    sprintf((char *)http_cmd1,http_cmd);
+
+    TCPconnection.send_all(http_cmd, sizeof(http_cmd));
+    
+    TCPconnection.receive_all(buffer, sizeof(buffer));
+    printf("%s",buffer);
+  
+	
+		return 0;
+	}
 //char* getNetworkMask();
+
+