Rangel Alvarado / Mbed 2 deprecated FRDM_K64F-Ethernet

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
issaiass
Date:
Mon Sep 22 02:34:12 2014 +0000
Commit message:
This example uses the FRDM-K64F board Ethernet interface with a static ip address connected directly to the PC

Changed in this revision

EthernetInterface.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 annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r bbc9cfdee3bc EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Mon Sep 22 02:34:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
diff -r 000000000000 -r bbc9cfdee3bc main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 22 02:34:12 2014 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+ 
+#define MBED_DEV_IP       "192.168.0.52"
+#define MBED_DEV_MASK     "255.255.255.0"
+#define MBED_DEV_GW       "0.0.0.0"
+#define ECHO_SERVER_PORT   5000
+
+ 
+int main (void) {
+    EthernetInterface eth;
+    eth.init(MBED_DEV_IP, MBED_DEV_MASK, MBED_DEV_GW); //Assign a device ip, mask and gateway
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    
+    TCPSocketServer server;
+    server.bind(ECHO_SERVER_PORT);
+    server.listen();
+    
+    while (true) {
+        printf("\nWait for new connection...\n");
+        TCPSocketConnection client;
+        server.accept(client);
+        client.set_blocking(false, 1500); // Timeout after (1.5)s
+        
+        printf("Connection from: %s\n", client.get_address());
+        char buffer[256];
+        while (true) {
+            int n = client.receive(buffer, sizeof(buffer));
+            if (n <= 0) break;
+            
+            client.send_all(buffer, n);
+            if (n <= 0) break;
+        }
+        
+        client.close();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r bbc9cfdee3bc mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Sep 22 02:34:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#631c0f1008c3
diff -r 000000000000 -r bbc9cfdee3bc mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 22 02:34:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file