Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
Fork of FRDM_K64F-Ethernet by
Revision 1:52ba06578336, committed 2015-04-19
- Comitter:
- dariusz777
- Date:
- Sun Apr 19 17:00:55 2015 +0000
- Parent:
- 0:bbc9cfdee3bc
- Child:
- 2:ff5c01165824
- Commit message:
- done
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Sep 22 02:34:12 2014 +0000
+++ b/main.cpp Sun Apr 19 17:00:55 2015 +0000
@@ -1,22 +1,27 @@
#include "mbed.h"
#include "EthernetInterface.h"
+#include "gets.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
+#define MBED_DEV_MASK "255.255.255.0"
+#define MBED_DEV_GW "0.0.0.0"
+#define ECHO_SERVER_PORT 80
+// 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.init();
eth.connect();
- printf("IP Address is %s\n", eth.getIPAddress());
+ printf("IP Address is %s\n", eth.getIPAddress()); //"192.168.0.52"
TCPSocketServer server;
server.bind(ECHO_SERVER_PORT);
server.listen();
-
+
while (true) {
printf("\nWait for new connection...\n");
TCPSocketConnection client;
@@ -27,12 +32,10 @@
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;
+ if(n>0){
+ getsth(buffer[0], eth, client);
+ n=0;
}
-
- client.close();
+ }
}
-}
\ No newline at end of file
+}
