* - BAP, A tiny LUFA based AVR Programmer: http://www.busware.de/tiki-index.php?page=BAP\r
* - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/\r
* - Lightweight CC110x USB dongle for 868MHz Protocols: http://busware.de/tiki-index.php?page=CUL\r
+ * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR\r
* - MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/\r
* - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3\r
- * - SEGA Megadrive/Super Nintendo Cartridge Reader: http://www.snega2usb.com\r
+ * - Retrode, a USB Games Console Cartridge Reader: http://www.snega2usb.com\r
* - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/\r
- * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR\r
*\r
* \section Sec_LUFAPublications Publications Mentioning LUFA\r
* - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue\r
* - Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue\r
+ * - Elektor Magazine, "20 x Open Source", March 2010 Issue\r
*/
\ No newline at end of file
* DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the\r
* DHCP server on the network.\r
*/\r
- \r
+\r
#include "DHCPClientApp.h"\r
\r
#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__)\r
-/** Timer for managing the timeout period for a DHCP server to respond */\r
-struct timer DHCPTimer;\r
\r
/** Initialization function for the DHCP client. */\r
void DHCPClientApp_Init(void)\r
if (Connection != NULL)\r
{\r
uip_udp_appstate_t* const AppState = &Connection->appstate;\r
-\r
uip_udp_bind(Connection, HTONS(DHCPC_CLIENT_PORT));\r
+ \r
+ /* Set the initial client state */\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
- }\r
\r
- /* Set timeout period to half a second for a DHCP server to respond */\r
- timer_set(&DHCPTimer, CLOCK_SECOND / 2);\r
+ /* Set timeout period to half a second for a DHCP server to respond */\r
+ timer_set(&AppState->DHCPClient.Timeout, CLOCK_SECOND / 2);\r
+ }\r
}\r
\r
/** uIP stack application callback for the DHCP client. This function must be called each time the TCP/IP stack \r
uip_udp_send(AppDataSize);\r
\r
/* Reset the timeout timer, progress to next state */\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForOffer; \r
\r
break;\r
if (!(uip_newdata()))\r
{\r
/* Check if the DHCP timeout period has expired while waiting for a response */\r
- if (timer_expired(&DHCPTimer))\r
+ if (timer_expired(&AppState->DHCPClient.Timeout))\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
\r
break;\r
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_ROUTER, &AppState->DHCPClient.DHCPOffer_Data.GatewayIP);\r
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_SERVER_ID, &AppState->DHCPClient.DHCPOffer_Data.ServerIP);\r
\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendRequest;\r
}\r
\r
uip_udp_send(AppDataSize);\r
\r
/* Reset the timeout timer, progress to next state */\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForACK;\r
\r
break;\r
if (!(uip_newdata()))\r
{\r
/* Check if the DHCP timeout period has expired while waiting for a response */\r
- if (timer_expired(&DHCPTimer))\r
+ if (timer_expired(&AppState->DHCPClient.Timeout))\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
\r
break;\r
/ Function and Buffer Configurations\r
/----------------------------------------------------------------------------*/\r
\r
-#define _FS_TINY 0 /* 0 or 1 */\r
+#define _FS_TINY 1 /* 0 or 1 */\r
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system\r
/ object instead of the sector buffer in the individual file object for file\r
/ data transfer. This reduces memory consumption 512 bytes each file object. */\r
/** HTTP server response header, for transmission before the page contents. This indicates to the host that a page exists at the\r
* given location, and gives extra connection information.\r
*/\r
-char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
- "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
- "Connection: close\r\n"\r
- "MIME-version: 1.0\r\n"\r
- "Content-Type: ";\r
+const char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
+ "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
+ "Connection: close\r\n"\r
+ "MIME-version: 1.0\r\n"\r
+ "Content-Type: ";\r
\r
/** HTTP server response header, for transmission before a resource not found error. This indicates to the host that the given\r
* given URL is invalid, and gives extra error information.\r
*/\r
-char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
- "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
- "Connection: close\r\n"\r
- "MIME-version: 1.0\r\n"\r
- "Content-Type: text/plain\r\n\r\n"\r
- "Error 404: File Not Found";\r
+const char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
+ "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
+ "Connection: close\r\n"\r
+ "MIME-version: 1.0\r\n"\r
+ "Content-Type: text/plain\r\n\r\n"\r
+ "Error 404: File Not Found";\r
\r
-/** Default MIME type sent if no other MIME type can be determined */\r
-char PROGMEM DefaultMIMEType[] = "text/plain";\r
+/** Default MIME type sent if no other MIME type can be determined. */\r
+const char PROGMEM DefaultMIMEType[] = "text/plain";\r
\r
/** List of MIME types for each supported file extension. */\r
-MIME_Type_t PROGMEM MIMETypes[] =\r
+const MIME_Type_t MIMETypes[] =\r
{\r
{.Extension = "htm", .MIMEType = "text/html"},\r
{.Extension = "jpg", .MIMEType = "image/jpeg"},\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
- char* HeaderToSend;\r
+ const char* HeaderToSend;\r
\r
/* Determine which HTTP header should be sent to the client */\r
if (AppState->HTTPServer.FileOpen)\r
/* Look through the MIME type list, copy over the required MIME type if found */\r
for (int i = 0; i < (sizeof(MIMETypes) / sizeof(MIMETypes[0])); i++)\r
{\r
- if (strcmp_P(&Extension[1], MIMETypes[i].Extension) == 0)\r
+ if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0)\r
{\r
- MIMEHeaderLength = strlen_P(MIMETypes[i].MIMEType);\r
- strncpy_P(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength); \r
+ MIMEHeaderLength = strlen(MIMETypes[i].MIMEType);\r
+ strncpy(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength); \r
break;\r
}\r
} \r
/** Type define for a MIME type handler. */\r
typedef struct\r
{\r
- char Extension[4]; /**< 3 or less character file extension */\r
- char MIMEType[30]; /**< Appropriate MIME type to send when the extension is encountered */\r
+ char* Extension; /**< File extension (no leading '.' character) */\r
+ char* MIMEType; /**< Appropriate MIME type to send when the extension is encountered */\r
} MIME_Type_t;\r
\r
/* Macros: */\r
#include "TELNETServerApp.h"\r
\r
/** Welcome message to send to a TELNET client when a connection is first made. */\r
-char PROGMEM WelcomeHeader[] = "********************************************\r\n"\r
- "* LUFA uIP Webserver (TELNET) *\r\n"\r
- "********************************************\r\n";\r
+const char PROGMEM WelcomeHeader[] = "********************************************\r\n"\r
+ "* LUFA uIP Webserver (TELNET) *\r\n"\r
+ "********************************************\r\n";\r
\r
/** Main TELNET menu, giving the user the list of available commands they may issue */\r
-char PROGMEM TELNETMenu[] = "\r\n"\r
- " Available Commands:\r\n"\r
- " c) List Active TCP Connections\r\n"\r
- "\r\nCommand>";\r
+const char PROGMEM TELNETMenu[] = "\r\n"\r
+ " Available Commands:\r\n"\r
+ " c) List Active TCP Connections\r\n"\r
+ "\r\nCommand>";\r
\r
/** Initialization function for the simple HTTP webserver. */\r
void TELNETServerApp_Init(void)\r
uip_setethaddr(MACAddress);\r
\r
/* DHCP/Server IP Settings Initialization */\r
- #if defined(ENABLE_DHCP)\r
+ #if defined(ENABLE_DHCP_CLIENT)\r
DHCPClientApp_Init();\r
#else\r
uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress;\r
#include <stdbool.h>
#include <stdint.h>
+#include "timer.h"
+
typedef uint8_t u8_t;
typedef uint16_t u16_t;
typedef uint32_t u32_t;
{
struct
{
- uint8_t CurrentState;
+ uint8_t CurrentState;
+ struct timer Timeout;
struct
{
* <td><b>Description:</b></td>\r
* </tr>\r
* <tr>\r
- * <td>ENABLE_DHCP_CLIENT=<i>x</i></td>\r
+ * <td>ENABLE_DHCP_CLIENT</td>\r
* <td>Makefile CDEFS</td>\r
- * <td>When set to 1, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server.\r
- * To disable DHCP and use the fixed address settings set elsewhere, set this to zero (do not undefine it).</td>\r
+ * <td>When defined, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server.</td>\r
* </tr>\r
* <tr>\r
* <td>DEVICE_IP_ADDRESS</td>\r
* <td>Lib/uIPManagement.h</td>\r
- * <td>IP address that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is zero).</td>\r
+ * <td>IP address that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is not defined).</td>\r
* </tr>\r
* <tr>\r
* <td>DEVICE_NETMASK</td>\r
* <td>Lib/uIPManagement.h</td>\r
- * <td>Netmask that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is zero).</td>\r
+ * <td>Netmask that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT is not defined).</td>\r
* </tr>\r
* <tr>\r
* <td>DEVICE_GATEWAY</td>\r
* <td>Lib/uIPManagement.h</td>\r
* <td>Default routing gateway that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT\r
- * is zero).</td>\r
+ * is not defined).</td>\r
* </tr>\r
* </table>\r
*/
\ No newline at end of file
\r
# Place -D or -U options here for C sources\r
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)\r
-CDEFS += -DENABLE_DHCP_CLIENT=1\r
+CDEFS += -DENABLE_DHCP_CLIENT\r
\r
-CDEFS += -DUIP_CONF_UDP=ENABLE_DHCP_CLIENT -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=5\r
+CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=5\r
CDEFS += -DUIP_CONF_MAX_LISTENPORTS=5 -DUIP_URGDATA=0 -DUIP_CONF_BUFFER_SIZE=1514 -DUIP_ARCH_CHKSUM=0 \r
CDEFS += -DUIP_CONF_LL_802154=0 -DUIP_CONF_LL_80211=0 -DUIP_CONF_ROUTER=0 -DUIP_CONF_ICMP6=0\r
CDEFS += -DUIP_ARCH_ADD32=0 -DUIP_CONF_ICMP_DEST_UNREACH=1 -DUIP_NEIGHBOR_CONF_ADDRTYPE=0\r