3 * FreeRTOS Kernel V10.0.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. If you wish to use our Amazon
\r
15 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * http://www.FreeRTOS.org
\r
25 * http://aws.amazon.com/freertos
\r
27 * 1 tab == 4 spaces!
\r
31 Implements a simplistic WEB server. Every time a connection is made and
\r
32 data is received a dynamic page that shows the current TCP/IP statistics
\r
33 is generated and returned. The connection is then closed.
\r
37 /*------------------------------------------------------------------------------*/
\r
39 /*------------------------------------------------------------------------------*/
\r
41 /* Standard includes. */
\r
45 /* Scheduler includes. */
\r
46 #include "FreeRTOS.h"
\r
50 /* Demo includes. */
\r
51 #include "BasicWEB.h"
\r
53 /* lwIP includes. */
\r
54 #include "lwip/api.h"
\r
55 #include "lwip/tcpip.h"
\r
56 #include "lwip/memp.h"
\r
57 #include "lwip/stats.h"
\r
58 #include "netif/loopif.h"
\r
62 #define lwipTCP_STACK_SIZE 600
\r
65 /*------------------------------------------------------------------------------*/
\r
67 /*------------------------------------------------------------------------------*/
\r
68 static struct netif EMAC_if;
\r
70 /*------------------------------------------------------------------------------*/
\r
72 /*------------------------------------------------------------------------------*/
\r
75 void vlwIPInit( void )
\r
77 /* Initialize lwIP and its interface layer. */
\r
84 sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);
\r
85 tcpip_init( NULL, NULL );
\r
86 sys_set_default_state();
\r
88 /*------------------------------------------------------------*/
\r
90 void vBasicWEBServer( void *pvParameters )
\r
92 struct ip_addr xIpAddr, xNetMast, xGateway;
\r
93 extern err_t ethernetif_init( struct netif *netif );
\r
95 /* Parameters are not used - suppress compiler error. */
\r
96 ( void ) pvParameters;
\r
98 /* Create and configure the EMAC interface. */
\r
99 IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
\r
100 IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
\r
101 IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
\r
102 netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );
\r
104 /* make it the default interface */
\r
105 netif_set_default( &EMAC_if );
\r
108 netif_set_up(&EMAC_if);
\r
110 /* Initialize HTTP */
\r
113 /* Nothing else to do. No point hanging around. */
\r
114 vTaskDelete( NULL );
\r