X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=boards%2Fsam3x-ek%2Fexamples%2Fsam3x-ek_http_server%2Fmain.c;h=78cf8d09636ad24fe1eae571ad0418c963c5c949;hb=710780c30a26bdbdebe3e92b6fde1af0b04a91a3;hp=276265a66418f804a839fefa8766cd32298a4df3;hpb=a40850b888e38a4ff88138639a22bfd373b8af81;p=bertos.git diff --git a/boards/sam3x-ek/examples/sam3x-ek_http_server/main.c b/boards/sam3x-ek/examples/sam3x-ek_http_server/main.c index 276265a6..78cf8d09 100644 --- a/boards/sam3x-ek/examples/sam3x-ek_http_server/main.c +++ b/boards/sam3x-ek/examples/sam3x-ek_http_server/main.c @@ -26,16 +26,21 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2010,2011 Develer S.r.l. (http://www.develer.com/) + * Copyright 2011 Develer S.r.l. (http://www.develer.com/) * * --> * * \author Andrea Righi + * \author Daniele Basile * - * \brief lwIP TCP/IP echo server listening on port 80. + * \brief Simple Http server. + * + * This simple web server read the site's pages from SD card, and manage + * the cases where SD is not present or page not found, using embedded pages. + * Quering from browser the /status page, the server return a json dictionary where are store + * some board status info, like board temperature, up-time, etc. */ -#include "bertos.c" #include "hw/hw_sd.h" #include "hw/hw_adc.h" @@ -65,6 +70,8 @@ #include +#include + #include #include @@ -152,7 +159,7 @@ static const char http_html_hdr_404[] = "HTTP/1.1 404 Not Found\r\nContent-type: static const char http_file_not_found[] = "\ \ \ -404 Not Found

404 Not Found

\ +404 Not Found

404 Not Found

\

The requested URL was not found on this server.


\
BeRTOS simple HTTP server
"; @@ -160,7 +167,7 @@ static const char http_file_not_found[] = "\ static const char http_sd_not_present[] = " \ \ \ -BeRTOS simple HTTP Server \ +BeRTOS simple HTTP Server \

BeRTOS simple HTTP Server

Simple Http server, the site's pages are stored on SD card, check it if is present.


\ www.BeRTOS.org \ "; @@ -206,8 +213,8 @@ int main(void) continue; //Update board status. - sprintf(status.local_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->remote_ip.addr)); - sprintf(status.last_connected_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->local_ip.addr)); + sprintf(status.last_connected_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->remote_ip.addr)); + sprintf(status.local_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->local_ip.addr)); status.tot_req++; rx_buf_conn = netconn_recv(client); @@ -225,9 +232,9 @@ int main(void) if (strlen(file_name) == 0) strcpy(file_name, "index.htm"); - if (!strcmp("bertos_jpg.jpg", file_name)) + if (!strcmp("bertos_logo_jpg.jpg", file_name)) { - netconn_write(client, bertos_jpg, sizeof(bertos_jpg), NETCONN_NOCOPY); + netconn_write(client, bertos_logo_jpg, bertos_logo_jpg_len, NETCONN_NOCOPY); } else if (!strcmp("status", file_name)) {