for znrobotics workshop

Dependencies:   DHT22 HTTPClient SDFileSystem WIZnet_Library mbed

Fork of archlink_Temperture_dweetio by Kevin Lee

This program is for seeed arch link, using wiznet w550 ethernet interface. not compatible with mbed ethernet interface.

Files at this revision

API Documentation at this revision

Comitter:
Kevin_Lee
Date:
Tue Jun 30 05:41:58 2015 +0000
Parent:
0:29bbc7eec5e1
Child:
2:8b304d2b4ca5
Commit message:
new project

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jun 30 03:40:02 2015 +0000
+++ b/main.cpp	Tue Jun 30 05:41:58 2015 +0000
@@ -4,9 +4,10 @@
 #include "WIZnetInterface.h"
 
 
-#define USE_DHCP 0
+#define USE_DHCP 1
 #define LOOPBACKPORT  5000
 int W5500_Test(void);
+
 SPI spi(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0);
 WIZnetInterface ethernet(&spi, p24, p17); // Spi ,cs, reset
 int ret, dummy, lv = 1;
@@ -22,6 +23,7 @@
 
 
 int main() {
+    char buffer[256];
     wait(1);
     pc.baud(115200);
     wait(1);
@@ -29,6 +31,32 @@
     
     if(W5500_Test() == 0) {
         printf("W5500 tested OK \r\n");
+        
+        TCPSocketServer server;
+        
+        server.bind(LOOPBACKPORT);
+        server.listen();
+        while(1) {
+            printf("\nWait for new connection...\r\n");
+            TCPSocketConnection client;
+            server.accept(client);
+            client.set_blocking(false,0); // Timeout = 0.
+            printf("Connection from: %s\r\n",client.get_address());
+            while (client.is_connected() == true) {
+                int n = client.receive(buffer,sizeof(buffer));
+                if (n > 0) {
+                    client.send_all(buffer,n);
+                } else {
+                }
+                if (client.is_fin_received()) {
+                    client.close();
+                } else {
+                }
+                
+            }
+            printf("Disconnected.\r\n");
+            
+        }
     }
     
     while(1) {