questo a me andava già da subito

Dependencies:   WIZ820ioInterface mbed

Fork of Seeed_Ethernet_Shield by Shields

Files at this revision

API Documentation at this revision

Comitter:
Wonderjack996
Date:
Wed Jul 11 10:50:18 2018 +0000
Parent:
7:758802529bb0
Commit message:
funziona

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 758802529bb0 -r eb977ef6d2ab main.cpp
--- a/main.cpp	Fri Feb 13 09:43:30 2015 +0000
+++ b/main.cpp	Wed Jul 11 10:50:18 2018 +0000
@@ -21,22 +21,26 @@
 
 Serial pc(USBTX, USBRX);
 
-/**
+/*
  * D11 - MOSI pin
- * D12 - MISO pin
+JNH * D12 - MISO pin
  * D13 - SCK pin
  * D10 - SEL pin
  * NC - Reset pin; use D5 otherwise the shield might get into reset loop
  */
 WIZ820ioInterface eth(D11, D12, D13, D10, D5);
 
+const char * IP_Addr    = "10.51.23.95";
+const char * IP_Subnet  = "255.255.255.0";
+const char * IP_Gateway = "10.51.70.254";
+unsigned char MAC_Addr[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
 int main()
 {
     wait(3);
     
     // Initialize the interface.
     // If no param is passed to init() then DHCP will be used on connect()
-    int s = eth.init();
+    int s = eth.init(IP_Addr,IP_Subnet,IP_Gateway);
     if (s != NULL) {
         printf(">>> Could not initialise. Halting!\n");
         exit(0);
@@ -55,35 +59,7 @@
     }
     printf(">>> Got IP address: %s\n", eth.getIPAddress());
 
-    // Prepare the http request to mbed.org
-    printf(">>> Open socket to mbed.org:80\n");
-    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
-    TCPSocketConnection sock;
-    
-    while (sock.connect("mbed.org", 80) == -1) {
-        printf(">>> Unable to open socket! Retrying ...\n");
-    };
-    
-    printf(">>> Request %s\n", http_cmd);
-    sock.send_all(http_cmd, sizeof(http_cmd)-1);
-
-    // Read the response
-    char buffer[300];
-    int ret;
-    while (true) {
-        ret = sock.receive(buffer, sizeof(buffer)-1);
-        if (ret <= 0)
-            break;
-        buffer[ret] = '\0';
-        printf(">>> Received %d chars from mbed.org:\n%s\n", ret, buffer);
-    }
-
-    printf(">>> Close socket\n");
-    sock.close();
-    
-    // Disconnect from network
-    printf(">>> Disconnect from network\n");
-    eth.disconnect();
+    while(true);
 
     return 0;
 }