Webserver and SDWriter on LPC4088QSB
Dependencies: mbed mbed-rtos EALib EthernetInterface
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "MCIFileSystem.h" 00004 #include "TCPSocketConnection.h" 00005 00006 MCIFileSystem mcifs("mci", NC); 00007 TCPSocketServer server; 00008 TCPSocketConnection client; 00009 00010 int main() { 00011 00012 FILE* fp1 = fopen("/mci/test1puta.txt", "a"); 00013 if (fp1) { 00014 fprintf(fp1, "Hello from EA Pechitos QSB\n"); 00015 for(int i = 0; i < 21; i++) { 00016 fprintf(fp1, " %d", i); 00017 //led2 = !led2; 00018 } 00019 fprintf(fp1, "\n"); 00020 fclose(fp1); 00021 } 00022 00023 EthernetInterface eth; 00024 eth.init(); //Use DHCP 00025 eth.connect(); 00026 printf("IP Address is %s\n", eth.getIPAddress()); 00027 00028 //server.open(ð); 00029 server.bind(80); 00030 server.listen(); 00031 00032 while (true) { 00033 printf("Server bound and listening\n"); 00034 00035 while (true) { 00036 server.accept(client); 00037 00038 printf("Client connected, stack at 0x%08lX\n", client); 00039 00040 char buffer[1024]; 00041 int n; //= client->recv(buffer, sizeof(buffer)); 00042 printf("Received %u bytes from remote host\n", n); 00043 00044 client.send("ESTO ES LA POLLA",16); 00045 client.close(); 00046 00047 } 00048 } 00049 }
Generated on Thu Jul 14 2022 11:34:18 by 1.7.2