WWW serwer SKM

Dependencies:   EthernetInterface SDFileSystem mbed-rtos mbed

Revision:
3:c05bbec8d96b
Parent:
2:8d5a84fcf90c
--- a/main.cpp	Mon Nov 13 17:06:43 2017 +0000
+++ b/main.cpp	Wed Dec 13 17:42:27 2017 +0000
@@ -4,109 +4,8 @@
 #include <string.h>
 #include <stdio.h>
 
-#define PORT 80
-
-const char *ip = "192.168.3.2";
-const char *mask = "255.255.255.0";
-const char *gateway = "192.168.3.2";
-
-Serial pc(USBTX, USBRX);
-EthernetInterface eth;                                                                                                  //uchwyt do Ethernet
-SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");                                                                          //inicjalizacja karty SD (MOSI,MISO,SCK,CS)
-TCPSocketConnection client;
-TCPSocketServer svr;
-
-bool server_is_listened = false;
-bool client_is_connected = false;
-
-void Send_Data_From_SD()
-{
-    int i = 0;
-    const char *index = "/sd/www/index.html";
-    //const char *style = "/sd/www/style.css";
-    //const char *alien = "/sd/www/img/alien.jpg";
-    //const char *forrest = "/sd/www/img/forrest.jpg";
-    char send_char[1];
-    FILE *fp = fopen(index, "r");
-    while (1) 
-    {
-        if (fgets(send_char,1, fp) == NULL) break;
-        client.send(send_char, 1);   //przerobic na get line
-        i++;
-    }
-    fclose(fp);      
-    /*
-    fp = fopen(style, "r");
-    while (fread(&send_char, sizeof(char), 1, fp) == 1) {        
-        client.send(&send_char, 1);
-    }
-    fclose(fp); 
-    fp = fopen(alien, "r");
-    while (fread(&send_char, sizeof(char), 1, fp) == 1) {        
-        client.send(&send_char, 1);
-    }
-    fclose(fp); 
-    fp = fopen(forrest, "r");
-    while (fread(&send_char, sizeof(char), 1, fp) == 1) {        
-        client.send(&send_char, 1);
-    }
-    fclose(fp); 
-    */
-    client_is_connected = false;
-    
-}
-void Initialize_Server(void) 
-{
-    eth.init(ip,mask,gateway);                                                                                          //inicjalizacja ethernet, statyczny adres ip
-    eth.connect();                                                                                                      //wlaczenie interfejsu
-    printf("Zainicjowano Ethernet! \n");                            
-    printf("Adres IP: %s\n",eth.getIPAddress());
-    printf("Maska: %s\n",eth.getNetworkMask());
-    printf("Brama: %s\n",eth.getGateway());
-    printf("Adres MAC urzadzenia: %s\n",eth.getMACAddress());
-    if (svr.bind(PORT) < 0) 
-    {
-        printf("Nie udalo sie powiazac serwera TCP z portem 80 (HTTP)! \n");
-        return;
-    }
-    else 
-    {
-        printf("Powiazano serwer TCP z portem 80 (HTTP). \n");
-        server_is_listened = true;
-    }
-    
-    if (svr.listen(1) < 0) 
-    {
-        printf("Nie udalo sie rozpoczac nasluchiwania polaczen przychodzacych serwera TCP! \n");
-        return;
-    }
-    else 
-    {        
-        printf("Serwer TCP rozpoczal nasluchiwanie polaczen przychodzacych. \n");
-    }    
-}
-
 int main() 
 {
-    pc.baud(9600);
-    printf("Zainicjowano UART! \n");
-    printf("Predkosc bitowa transmisji - 9600b/s.\n");
-    Initialize_Server();
-    while (server_is_listened) {
-        if (svr.accept(client)) 
-        {
-            printf("Nie udalo sie zaakceptowac polaczenia z klientem! \n");
-        }
-        else 
-        {
-            printf("Polaczono z klientem. IP klienta: %s\n", client.get_address());
-            client_is_connected = true;
-            while (client_is_connected)
-            {  
-                Send_Data_From_SD();
-            }
-            client.close();
-            printf("Wyslano dane do klienta i rozlaczono sesje. \n");
-        }
-    }
+    
+    return 0;
 }