3 * FreeRTOS Kernel V10.1.0
\r
4 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
7 * this software and associated documentation files (the "Software"), to deal in
\r
8 * the Software without restriction, including without limitation the rights to
\r
9 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
10 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
11 * subject to the following conditions:
\r
13 * The above copyright notice and this permission notice shall be included in all
\r
14 * copies or substantial portions of the Software.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
30 Implements a simplistic WEB server. Every time a connection is made and
\r
31 data is received a dynamic page that shows the current TCP/IP statistics
\r
32 is generated and returned. The connection is then closed.
\r
36 /*------------------------------------------------------------------------------*/
\r
38 /*------------------------------------------------------------------------------*/
\r
40 /* Standard includes. */
\r
44 /* Scheduler includes. */
\r
45 #include "FreeRTOS.h"
\r
49 /* Demo includes. */
\r
50 #include "BasicWEB.h"
\r
52 /* lwIP includes. */
\r
53 #include "lwip/api.h"
\r
54 #include "lwip/tcpip.h"
\r
55 #include "lwip/memp.h"
\r
56 #include "lwip/stats.h"
\r
57 #include "netif/loopif.h"
\r
61 #define lwipTCP_STACK_SIZE 600
\r
64 /*------------------------------------------------------------------------------*/
\r
66 /*------------------------------------------------------------------------------*/
\r
67 static struct netif EMAC_if;
\r
69 /*------------------------------------------------------------------------------*/
\r
71 /*------------------------------------------------------------------------------*/
\r
74 void vlwIPInit( void )
\r
76 /* Initialize lwIP and its interface layer. */
\r
83 sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);
\r
84 tcpip_init( NULL, NULL );
\r
85 sys_set_default_state();
\r
87 /*------------------------------------------------------------*/
\r
89 void vBasicWEBServer( void *pvParameters )
\r
91 struct ip_addr xIpAddr, xNetMast, xGateway;
\r
92 extern err_t ethernetif_init( struct netif *netif );
\r
94 /* Parameters are not used - suppress compiler error. */
\r
95 ( void ) pvParameters;
\r
97 /* Create and configure the EMAC interface. */
\r
98 IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
\r
99 IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
\r
100 IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
\r
101 netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );
\r
103 /* make it the default interface */
\r
104 netif_set_default( &EMAC_if );
\r
107 netif_set_up(&EMAC_if);
\r
109 /* Initialize HTTP */
\r
112 /* Nothing else to do. No point hanging around. */
\r
113 vTaskDelete( NULL );
\r