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: mbed mbed-rtos EALib EthernetInterface
Revision 15:08bea8ac9e64, committed 2019-05-08
- Comitter:
- bertonieto
- Date:
- Wed May 08 12:04:58 2019 +0000
- Parent:
- 14:72be2b8b7f24
- Commit message:
- Este programa escribe sobre una sd en un LPC4088 y tiene un servidor http
Changed in this revision
| EALib.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EALib.lib Wed May 08 12:04:58 2019 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/embeddedartists/code/EALib/#d868b74fd08e
--- a/main.cpp Wed May 14 15:07:26 2014 +0000
+++ b/main.cpp Wed May 08 12:04:58 2019 +0000
@@ -1,31 +1,49 @@
#include "mbed.h"
#include "EthernetInterface.h"
+#include "MCIFileSystem.h"
+#include "TCPSocketConnection.h"
+
+MCIFileSystem mcifs("mci", NC);
+TCPSocketServer server;
+TCPSocketConnection client;
int main() {
+
+ FILE* fp1 = fopen("/mci/test1puta.txt", "a");
+ if (fp1) {
+ fprintf(fp1, "Hello from EA Pechitos QSB\n");
+ for(int i = 0; i < 21; i++) {
+ fprintf(fp1, " %d", i);
+ //led2 = !led2;
+ }
+ fprintf(fp1, "\n");
+ fclose(fp1);
+ }
+
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
- TCPSocketConnection sock;
- sock.connect("mbed.org", 80);
+ //server.open(ð);
+ server.bind(80);
+ server.listen();
- char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
- sock.send_all(http_cmd, sizeof(http_cmd)-1);
-
- 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 server:\n%s\n", ret, buffer);
+ printf("Server bound and listening\n");
+
+ while (true) {
+ server.accept(client);
+
+ printf("Client connected, stack at 0x%08lX\n", client);
+
+ char buffer[1024];
+ int n; //= client->recv(buffer, sizeof(buffer));
+ printf("Received %u bytes from remote host\n", n);
+
+ client.send("ESTO ES LA POLLA",16);
+ client.close();
+
+ }
}
-
- sock.close();
-
- eth.disconnect();
-
- while(1) {}
}