Webserver and SDWriter on LPC4088QSB

Dependencies:   mbed mbed-rtos EALib EthernetInterface

Committer:
bertonieto
Date:
Wed May 08 12:04:58 2019 +0000
Revision:
15:08bea8ac9e64
Parent:
11:59dcefdda506
Este programa escribe sobre una sd en un LPC4088 y tiene un servidor http

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:bb128f0e952f 1 #include "mbed.h"
donatien 0:bb128f0e952f 2 #include "EthernetInterface.h"
bertonieto 15:08bea8ac9e64 3 #include "MCIFileSystem.h"
bertonieto 15:08bea8ac9e64 4 #include "TCPSocketConnection.h"
bertonieto 15:08bea8ac9e64 5
bertonieto 15:08bea8ac9e64 6 MCIFileSystem mcifs("mci", NC);
bertonieto 15:08bea8ac9e64 7 TCPSocketServer server;
bertonieto 15:08bea8ac9e64 8 TCPSocketConnection client;
donatien 0:bb128f0e952f 9
emilmont 7:65188f4a8c25 10 int main() {
bertonieto 15:08bea8ac9e64 11
bertonieto 15:08bea8ac9e64 12 FILE* fp1 = fopen("/mci/test1puta.txt", "a");
bertonieto 15:08bea8ac9e64 13 if (fp1) {
bertonieto 15:08bea8ac9e64 14 fprintf(fp1, "Hello from EA Pechitos QSB\n");
bertonieto 15:08bea8ac9e64 15 for(int i = 0; i < 21; i++) {
bertonieto 15:08bea8ac9e64 16 fprintf(fp1, " %d", i);
bertonieto 15:08bea8ac9e64 17 //led2 = !led2;
bertonieto 15:08bea8ac9e64 18 }
bertonieto 15:08bea8ac9e64 19 fprintf(fp1, "\n");
bertonieto 15:08bea8ac9e64 20 fclose(fp1);
bertonieto 15:08bea8ac9e64 21 }
bertonieto 15:08bea8ac9e64 22
donatien 0:bb128f0e952f 23 EthernetInterface eth;
donatien 0:bb128f0e952f 24 eth.init(); //Use DHCP
donatien 0:bb128f0e952f 25 eth.connect();
emilmont 2:e087e9b789e9 26 printf("IP Address is %s\n", eth.getIPAddress());
donatien 0:bb128f0e952f 27
bertonieto 15:08bea8ac9e64 28 //server.open(&eth);
bertonieto 15:08bea8ac9e64 29 server.bind(80);
bertonieto 15:08bea8ac9e64 30 server.listen();
donatien 0:bb128f0e952f 31
emilmont 7:65188f4a8c25 32 while (true) {
bertonieto 15:08bea8ac9e64 33 printf("Server bound and listening\n");
bertonieto 15:08bea8ac9e64 34
bertonieto 15:08bea8ac9e64 35 while (true) {
bertonieto 15:08bea8ac9e64 36 server.accept(client);
bertonieto 15:08bea8ac9e64 37
bertonieto 15:08bea8ac9e64 38 printf("Client connected, stack at 0x%08lX\n", client);
bertonieto 15:08bea8ac9e64 39
bertonieto 15:08bea8ac9e64 40 char buffer[1024];
bertonieto 15:08bea8ac9e64 41 int n; //= client->recv(buffer, sizeof(buffer));
bertonieto 15:08bea8ac9e64 42 printf("Received %u bytes from remote host\n", n);
bertonieto 15:08bea8ac9e64 43
bertonieto 15:08bea8ac9e64 44 client.send("ESTO ES LA POLLA",16);
bertonieto 15:08bea8ac9e64 45 client.close();
bertonieto 15:08bea8ac9e64 46
bertonieto 15:08bea8ac9e64 47 }
emilmont 7:65188f4a8c25 48 }
donatien 0:bb128f0e952f 49 }