Simple HTTP server example with WIZ550io, W5500 (WIZnet chipset) .access the mbed via any browser, mbed echo back http request header.

Dependencies:   W5500Interface mbed

Fork of HTTPServer_echoback_WIZ550io by Bongjun Hur

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Mon Jul 21 05:13:27 2014 +0000
Parent:
15:eae1575da9ca
Child:
17:c42419afb2f8
Commit message:
HTTPServer echo back example for WIZ550io, W5500 ( WIZnet chipset); Ethernet connection.

Changed in this revision

EthernetInterface.lib Show diff for this revision Revisions of this file
EthernetInterfaceW5500.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Fri Mar 08 02:24:33 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#9b2d10dc0392
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterfaceW5500.lib	Mon Jul 21 05:13:27 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/EthernetInterfaceW5500-makers/code/EthernetInterfaceW5500/#d130abe9d4a8
--- a/main.cpp	Fri Mar 08 02:24:33 2013 +0000
+++ b/main.cpp	Mon Jul 21 05:13:27 2014 +0000
@@ -1,18 +1,18 @@
 #include "mbed.h"
-#include "EthernetInterface.h"
+//#include "EthernetInterface.h"
+#include "EthernetInterfaceW5500.h"
 #include <stdio.h>
 #include <string.h>
 
 #define PORT   80
 
-EthernetInterface eth;
+//EthernetInterface eth;
 
-TCPSocketServer svr;
+//TCPSocketServer svr;
 bool serverIsListened = false;
 
-TCPSocketConnection client;
+//TCPSocketConnection client;
 bool clientIsConnected = false;
-
 DigitalOut led1(LED1); //server listning status
 DigitalOut led2(LED2); //socket connecting status
 
@@ -29,12 +29,58 @@
 
 int main (void)
 {
+#if defined(TARGET_LPC1114)
+    SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
+    EthernetInterfaceW5500 eth(&spi, dp25, dp26); // spi, cs, reset
+
+#elif defined(TARGET_LPC1768)
+    SPI spi(p11, p12, p13); // mosi, miso, sclk
+    EthernetInterfaceW5500 eth(&spi, p14, p15); // spi, cs, reset
+
+#elif defined(TARGET_LPC11U68)
+    SPI spi(P0_9, P0_8, P1_29); // mosi, miso, sclk
+//WIZnetInterface eth(&spi, P0_2, P1_25); // spi, cs, reset
+//SPI spi(p5, p6, p7); // mosi, miso, sclk
+    EthernetInterfaceW5500 eth(&spi, P0_2, P1_28);//, nRESET(p9); // reset pin is dummy, don't affect any pin of WIZ550io
+    spi.format(8,0); // 8bit, mode 0
+    spi.frequency(7000000); // 7MHz
+    wait(1); // 1 second for stable state
+
+#endif
+
+TCPSocketServer svr;
+TCPSocketConnection client;
+
     ledTick.attach(&ledTickfunc,0.5);
 
+/*
     //setup ethernet interface
     eth.init(); //Use DHCP
     eth.connect();
     printf("IP Address is %s\n\r", eth.getIPAddress());
+*/
+
+#ifdef _DHCP // didn't test yet in DHCP
+
+    eth.init(); //Use DHCP
+    eth.connect();
+    //printf("IP Address is %s\n\r", eth.getIPAddress());
+    printf("Initialized, MAC: %s\n", eth.getMACAddress());
+    printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+           eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+
+#else
+    // as your env. change to real IP address and so on.
+    int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+    if (!ret) {
+        printf("Initialized, MAC: %s\n", eth.getMACAddress());
+        printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+               eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+    } else {
+        printf("Error eth.init() - ret = %d\n", ret);
+        return -1;
+    }
+#endif
 
     //setup tcp socket
     if(svr.bind(PORT)< 0) {
--- a/mbed-rtos.lib	Fri Mar 08 02:24:33 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782
--- a/mbed.bld	Fri Mar 08 02:24:33 2013 +0000
+++ b/mbed.bld	Mon Jul 21 05:13:27 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file