/* Standard includes. */\r
#include <string.h>\r
\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "semphr.h"\r
+\r
/* lwIP core includes */\r
#include "lwip/opt.h"\r
-#include "lwip/sys.h"\r
-#include "lwip/timers.h"\r
-#include "lwip/debug.h"\r
-#include "lwip/stats.h"\r
-#include "lwip/init.h"\r
#include "lwip/tcpip.h"\r
-#include "lwip/netif.h"\r
-#include "lwip/tcp.h"\r
-#include "lwip/udp.h"\r
-#include "lwip/dns.h"\r
-#include "lwip/dhcp.h"\r
-#include "lwip/autoip.h"\r
\r
/* lwIP netif includes */\r
#include "netif/etharp.h"\r
/* applications includes */\r
#include "apps/httpserver_raw/httpd.h"\r
\r
-\r
+/* The constants that define the IP address, net mask, gateway address and MAC\r
+address are located at the bottom of FreeRTOSConfig.h. */\r
#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 )\r
#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), configGW_IP_ADDR0, configGW_IP_ADDR1, configGW_IP_ADDR2, configGW_IP_ADDR3 )\r
#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), configNET_MASK0,configNET_MASK1,configNET_MASK2,configNET_MASK3)\r
-\r
-/* remember to change this MAC address to suit your needs!\r
- the last octet will be increased by netif->num for each netif */\r
#define LWIP_MAC_ADDR_BASE { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }\r
\r
-/* configuration for applications */\r
-\r
-#define LWIP_CHARGEN_APP 0\r
-#define LWIP_DNS_APP 0\r
-#define LWIP_HTTPD_APP 1\r
-\r
-static struct netif netif;\r
-\r
-static void apps_init( void );\r
-\r
+/* Definitions of the various SSI callback functions within the pccSSITags \r
+array. If pccSSITags is updated, then these definitions must also be updated. */\r
#define ssiTASK_STATS_INDEX 0\r
#define ssiRUN_TIME_STATS_INDEX 1\r
\r
-\r
/*\r
* The SSI handler callback function passed to lwIP.\r
*/\r
static unsigned short uslwIPAppsSSIHandler( int iIndex, char *pcBuffer, int iBufferLength );\r
\r
+/*-----------------------------------------------------------*/\r
\r
-/* The SSI strings that are embedded in the served html files. */\r
+/* The SSI strings that are embedded in the served html files. If this array\r
+is changed, then the index position defined by the #defines such as \r
+ssiTASK_STATS_INDEX above must also be updated. */\r
static const char *pccSSITags[] = \r
{\r
"rtos_stats",\r
"run_stats"\r
};\r
\r
+/*-----------------------------------------------------------*/\r
\r
/* Called from the TCP/IP thread. */\r
void lwIPAppsInit( void *pvArgument )\r
{\r
-ip_addr_t ipaddr, netmask, gw;\r
-extern err_t ethernetif_init( struct netif *netif );\r
+ip_addr_t xIPAddr, xNetMask, xGateway;\r
+extern err_t ethernetif_init( struct netif *xNetIf );\r
+static struct netif xNetIf;\r
\r
( void ) pvArgument;\r
\r
- ip_addr_set_zero( &gw );\r
- ip_addr_set_zero( &ipaddr );\r
- ip_addr_set_zero( &netmask );\r
+ /* Set up the network interface. */\r
+ ip_addr_set_zero( &xGateway );\r
+ ip_addr_set_zero( &xIPAddr );\r
+ ip_addr_set_zero( &xNetMask );\r
\r
- LWIP_PORT_INIT_GW(&gw);\r
- LWIP_PORT_INIT_IPADDR(&ipaddr);\r
- LWIP_PORT_INIT_NETMASK(&netmask);\r
+ LWIP_PORT_INIT_GW(&xGateway);\r
+ LWIP_PORT_INIT_IPADDR(&xIPAddr);\r
+ LWIP_PORT_INIT_NETMASK(&xNetMask);\r
\r
- netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input));\r
+ netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway, NULL, ethernetif_init, tcpip_input ) );\r
+ netif_set_up( &xNetIf );\r
\r
- netif_set_up( &netif );\r
- apps_init();\r
- http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );\r
-}\r
-/*-----------------------------------------------------------*/\r
+ /* Initialise the raw http server. */\r
+ httpd_init();\r
\r
-/* This function initializes applications */\r
-static void apps_init( void )\r
-{\r
- /* Taken from the lwIP example code. */\r
- \r
- #if LWIP_HTTPD_APP && LWIP_TCP\r
- {\r
- httpd_init();\r
- }\r
- #endif /* LWIP_HTTPD_APP && LWIP_TCP */\r
+ /* Install the server side include handler. */\r
+ http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );\r
}\r
/*-----------------------------------------------------------*/\r
\r
static char cUpdateString[ 200 ];\r
extern char *pcMainGetTaskStatusMessage( void );\r
\r
+ /* Unused parameter. */\r
( void ) iBufferLength;\r
\r
/* The SSI handler function that generates text depending on the index of\r
break;\r
}\r
\r
+ /* Include a count of the number of times an SSI function has been executed\r
+ in the returned string. */\r
uiUpdateCount++;\r
sprintf( cUpdateString, "\r\n\r\n%u\r\nStatus - %s", uiUpdateCount, pcMainGetTaskStatusMessage() );\r
strcat( pcBuffer, cUpdateString );\r