From 60c71e3a07dca1716da0368906eff16ec9d90fab Mon Sep 17 00:00:00 2001 From: emaker-11z Date: Mon, 23 Sep 2013 16:23:38 +0100 Subject: [PATCH] Configured to use standard separate library. --- .cproject | 13 +- .project | 16 +- .settings/language.settings.xml | 2 +- .settings/org.eclipse.cdt.core.prefs | 43 +++- Configuration.h | 6 + GCodes.cpp | 14 +- Platform.cpp | 109 +++++---- network/ethernet_sam.c | 236 +++++++++++++++++++ network/ethernet_sam.h | 85 +++++++ network/httpserver_raw/fs.c | 64 +++++ network/httpserver_raw/fs.h | 44 ++++ network/httpserver_raw/fsdata.c | 339 +++++++++++++++++++++++++++ network/httpserver_raw/fsdata.h | 57 +++++ network/httpserver_raw/httpd.c | 254 ++++++++++++++++++++ network/httpserver_raw/httpd.h | 37 +++ network/lwip_test.h | 33 +++ network/lwipopts.h | 253 ++++++++++++++++++++ network/timer_mgt_sam.c | 147 ++++++++++++ network/timer_mgt_sam.h | 57 +++++ 19 files changed, 1749 insertions(+), 60 deletions(-) create mode 100644 network/ethernet_sam.c create mode 100644 network/ethernet_sam.h create mode 100644 network/httpserver_raw/fs.c create mode 100644 network/httpserver_raw/fs.h create mode 100644 network/httpserver_raw/fsdata.c create mode 100644 network/httpserver_raw/fsdata.h create mode 100644 network/httpserver_raw/httpd.c create mode 100644 network/httpserver_raw/httpd.h create mode 100644 network/lwip_test.h create mode 100644 network/lwipopts.h create mode 100644 network/timer_mgt_sam.c create mode 100644 network/timer_mgt_sam.h diff --git a/.cproject b/.cproject index 628129a..9b4aaf1 100644 --- a/.cproject +++ b/.cproject @@ -26,6 +26,11 @@ + + + + + @@ -38,6 +43,11 @@ + + + + + @@ -57,11 +67,12 @@ - + + diff --git a/.project b/.project index 88124b4..2c6bee3 100644 --- a/.project +++ b/.project @@ -26,6 +26,16 @@ it.baeyens.arduinonature + + Libraries/EMAC + 2 + ArduinoPivateLibPath/EMAC + + + Libraries/Lwip + 2 + ArduinoPivateLibPath/Lwip + Libraries/MCP4461 2 @@ -60,15 +70,15 @@ ArduinoHardwareLibPath - file:/usr/local/arduino-1.5.2/hardware/arduino/sam/libraries + file:/usr/local/arduino-1.5.4/hardware/arduino/sam/libraries ArduinoPinPath - file:/usr/local/arduino-1.5.2/hardware/arduino/sam/variants + file:/usr/local/arduino-1.5.4/hardware/arduino/sam/variants ArduinoPlatformPath - file:/usr/local/arduino-1.5.2/hardware/arduino/sam + file:/usr/local/arduino-1.5.4/hardware/arduino/sam diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 766010e..ae07477 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -3,7 +3,7 @@ - + diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs index a046f8c..1c2864f 100644 --- a/.settings/org.eclipse.cdt.core.prefs +++ b/.settings/org.eclipse.cdt.core.prefs @@ -2,12 +2,15 @@ eclipse.preferences.version=1 environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.ARCHIVE_FILE/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.ARCHIVE_FILE/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.ARCHIVE_FILE/value=arduino.ar +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.BOARD/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.BOARD/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.BOARD/value=SAM_DUE environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.CORE/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.CORE/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.CORE/value=arduino environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.EXTRA_FLAGS/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.EXTRA_FLAGS/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.EXTRA_FLAGS/value=-D__SAM3X8E__ -mthumb -DUSB_PID\=${A.BUILD.PID} -DUSB_VID\=${A.BUILD.VID} -DUSBCON +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.EXTRA_FLAGS/value=-D__SAM3X8E__ -mthumb ${A.BUILD.USB_FLAGS} environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.F_CPU/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.F_CPU/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.F_CPU/value=84000000L @@ -32,12 +35,21 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD. environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.SYSTEM.PATH/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.SYSTEM.PATH/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.SYSTEM.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/arduino/sam/system +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_FLAGS/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_FLAGS/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_FLAGS/value=-DUSB_VID\=${A.BUILD.VID} -DUSB_PID\=${A.BUILD.PID} -DUSBCON '-DUSB_MANUFACTURER\=${A.BUILD.USB_MANUFACTURER}' '-DUSB_PRODUCT\=${A.BUILD.USB_PRODUCT}' +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_MANUFACTURER/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_MANUFACTURER/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_MANUFACTURER/value="Unknown" +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_PRODUCT/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_PRODUCT/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USB_PRODUCT/value="Arduino Due" environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USE_ARCHIVER/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USE_ARCHIVER/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.USE_ARCHIVER/value=true environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT.PATH/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT.PATH/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT.PATH/value=/usr/local/arduino-1.5.2/hardware/arduino/sam/variants/${A.BUILD.VARIANT} +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT.PATH/value=/usr/local/arduino-1.5.4/hardware/arduino/sam/variants/${A.BUILD.VARIANT} environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.BUILD.VARIANT/value=arduino_due_x @@ -116,6 +128,9 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.NAME/v environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PATH/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PATH/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PATH/value=${A.TOOLS.BOSSAC.PATH} +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PID.0/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PID.0/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.PID.0/value=0x003e environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.AR.PATTERN.1/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.AR.PATTERN.1/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.AR.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" @@ -136,7 +151,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} -mcpu\=${A.BUILD.MCU} "-T${A.BUILD.VARIANT.PATH}/${A.BUILD.LDSCRIPT}" "-Wl,-Map,${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.map" -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "-L${A.BUILD.PATH}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry\=Reset_Handler -Wl,--unresolved-symbols\=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "${A.BUILD.PATH}/arduino/syscalls_sam3.c.o" ${A.OBJECT_FILES} "${A.BUILD.VARIANT.PATH}/${A.BUILD.VARIANT_SYSTEM_LIB}" "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" -Wl,--end-group environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.1/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.1/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.C.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.C.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.2/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.2/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.2/value=\ -o @@ -145,10 +160,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN.3/value= environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.C.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.C.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.C.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.1/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.1/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.2/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.2/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.2/value=\ -o @@ -157,7 +172,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN.3/value= environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.CPP.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.BUILD.EXTRA_FLAGS} ${A.COMPILER.LIBSAM.C.FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.OBJCOPY.EEP.PATTERN.1/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.OBJCOPY.EEP.PATTERN.1/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.OBJCOPY.EEP.PATTERN.1/value= @@ -181,10 +196,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RECIPE.SIZE.REGEX/value=\\.text\\s+([0-9]+).* environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.PATH/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.PATH/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.PATH/value=/usr/local/arduino-1.5.2 +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.PATH/value=/usr/local/arduino-1.5.4 environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.VERSION/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.VERSION/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.VERSION/value=152 +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.RUNTIME.IDE.VERSION/value=154 environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.SOFTWARE/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.SOFTWARE/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.SOFTWARE/value=ARDUINO @@ -224,9 +239,15 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.UPLOAD environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/value=true +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VERSION/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VERSION/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VERSION/value=1.5.4 +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VID.0/delimiter=\: +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VID.0/operation=replace +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/A.VID.0/value=0x2341 environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARDS_FILE/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARDS_FILE/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARDS_FILE/value=/usr/local/arduino-1.5.2/hardware/arduino/sam/boards.txt +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARDS_FILE/value=/usr/local/arduino-1.5.4/hardware/arduino/sam/boards.txt environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARD_NAME/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARD_NAME/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.BOARD_NAME/value=Arduino Due (Native USB Port) @@ -244,7 +265,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.E environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.EXTRA.CPP.COMPILE/value= environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.PLATFORM_FILE/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.PLATFORM_FILE/operation=replace -environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.PLATFORM_FILE/value=/usr/local/arduino-1.5.2/hardware/arduino/sam/platform.txt +environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.PLATFORM_FILE/value=/usr/local/arduino-1.5.4/hardware/arduino/sam/platform.txt environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.Processor/delimiter=\: environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.Processor/operation=replace environment/project/it.baeyens.arduino.core.toolChain.release.674980254/JANTJE.Processor/value= @@ -260,7 +281,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.674980254/PATH/val environment/project/it.baeyens.arduino.core.toolChain.release.674980254/append=true environment/project/it.baeyens.arduino.core.toolChain.release.674980254/appendContributed=true indexer/indexAllFiles=true -indexer/indexOnOpen=false +indexer/indexOnOpen=true indexer/indexUnusedHeadersWithAlternateLang=false indexer/indexUnusedHeadersWithDefaultLang=true indexer/indexerId=org.eclipse.cdt.core.fastIndexer diff --git a/Configuration.h b/Configuration.h index 37d48f7..4f02b1e 100644 --- a/Configuration.h +++ b/Configuration.h @@ -49,4 +49,10 @@ Licence: GPL */ #define ETHERNET 0 +/* Z PROBE CALIBRATION + * Set = 1 to enable Z probe ADC output on SerialUSb + */ +#define CALIB_Z 1 + + #endif diff --git a/GCodes.cpp b/GCodes.cpp index e453240..0d19ad4 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -635,7 +635,8 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) break; case 20: - platform->Message(HOST_MESSAGE, "List files received\n"); + platform->GetLine()->Write("GCode files:\n"); + platform->GetLine()->Write(platform->GetMassStorage()->FileList(platform->GetGCodeDir())); break; case 23: // Set file to print @@ -660,12 +661,15 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) drivesRelative = true; break; - case 105: // Depricated... - for(int8_t i = 0; i < HEATERS; i++) + case 105: // Deprecated... + platform->GetLine()->Write("ok T:"); + for(int8_t i = HEATERS - 1; i > 0; i--) { platform->GetLine()->Write(ftoa(NULL, reprap.GetHeat()->GetTemperature(i), 1)); platform->GetLine()->Write(" "); } + platform->GetLine()->Write("B:"); + platform->GetLine()->Write(ftoa(NULL, reprap.GetHeat()->GetTemperature(0), 1)); platform->GetLine()->Write('\n'); break; @@ -686,6 +690,10 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) reprap.debug(gb->GetIValue()); break; + case 114: // Deprecated + platform->GetLine()->Write("ok\n"); + break; + case 120: result = Push(); break; diff --git a/Platform.cpp b/Platform.cpp index 602e9c0..d1d510a 100644 --- a/Platform.cpp +++ b/Platform.cpp @@ -351,38 +351,63 @@ char* MassStorage::CombineName(char* directory, char* fileName) char* MassStorage::FileList(char* directory) { // File dir, entry; -// dir = SD.open(directory); -// int p = 0; + DIR dir; + FILINFO entry; + FRESULT res; + char loc[64]; + int len = 0; + + len = strlen(directory); + strncpy(loc,directory,len-1); + loc[len - 1 ] = '\0'; + + if(reprap.debug()) { + SerialUSB.print("Opening: "); + SerialUSB.println(loc); + } + + res = f_opendir(&dir,loc); + if(FR_OK == res) { + + if(reprap.debug()) { + SerialUSB.println("Directory open"); + } + + int p = 0; // int q; -// int count = 0; -// while(entry = dir.openNextFile()) -// { -// q = 0; -// count++; -// fileList[p++] = FILE_LIST_BRACKET; -// while(entry.name()[q]) -// { -// fileList[p++] = entry.name()[q]; -// q++; -// if(p >= FILE_LIST_LENGTH - 10) // Caution... -// { -// platform->Message(HOST_MESSAGE, "FileList - directory: "); -// platform->Message(HOST_MESSAGE, directory); -// platform->Message(HOST_MESSAGE, " has too many files!\n"); -// return ""; -// } -// } -// fileList[p++] = FILE_LIST_BRACKET; -// fileList[p++] = FILE_LIST_SEPARATOR; -// entry.close(); -// } -// dir.close(); -// -// if(count <= 0) -// return ""; -// -// fileList[--p] = 0; // Get rid of the last separator -// return fileList; + int foundFiles = 0; + + f_readdir(&dir,0); + while(FR_OK == f_readdir(&dir,&entry) && foundFiles < 24) + { + foundFiles++; + if(strlen(entry.fname) > 0) { + int q = 0; + fileList[p++] = FILE_LIST_BRACKET; + while(entry.fname[q]) + { + fileList[p++] = entry.fname[q]; + q++; + if(p >= FILE_LIST_LENGTH - 10) // Caution... + { + platform->Message(HOST_MESSAGE, "FileList - directory: "); + platform->Message(HOST_MESSAGE, directory); + platform->Message(HOST_MESSAGE, " has too many files!\n"); + return ""; + } + } + fileList[p++] = FILE_LIST_BRACKET; + fileList[p++] = FILE_LIST_SEPARATOR; + } + } + + if(foundFiles <= 0) + return "NONE"; + + fileList[--p] = 0; // Get rid of the last separator + return fileList; + } + SerialUSB.println(res); return ""; } @@ -658,10 +683,11 @@ void Platform::Message(char type, char* message) //*************************************************************************************************** +#if CALIB_Z + int zcount; // NASTY - FIX ME +#endif -// int zcount; // NASTY - FIX ME - uncomment to calibrate z probe - -void Platform::Spin() + void Platform::Spin() { if(!active) return; @@ -677,13 +703,14 @@ void Platform::Spin() PollZHeight(); lastTime = Time(); -// uncomment to calibrate z probe -// zcount++; -// if(zcount > 30) -// { -// zcount = 0; -// SerialUSB.println(GetRawZHeight()); -// } +#if CALIB_Z + zcount++; + if(zcount > 30) + { + zcount = 0; + SerialUSB.println(GetRawZHeight()); + } +#endif } Line::Line() diff --git a/network/ethernet_sam.c b/network/ethernet_sam.c new file mode 100644 index 0000000..3fe93dc --- /dev/null +++ b/network/ethernet_sam.c @@ -0,0 +1,236 @@ +/** + * \file + * + * \brief Ethernet management for the standalone lwIP example. + * + * Copyright (c) 2012 Atmel Corporation. All rights reserved. + * + * \asf_license_start + * + * \page License + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of Atmel may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 4. This software may only be redistributed and used in connection with an + * Atmel microcontroller product. + * + * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * \asf_license_stop + * + */ + +#include +//#include "board.h" +//#include "gpio.h" +#include "ethernet_sam.h" +//#include "emac.h" +#include "ethernet_phy.h" +#include "timer_mgt_sam.h" +//#include "sysclk.h" +/* lwIP includes */ +#include "lwip/src/include/lwip/sys.h" +#include "lwip/src/include/lwip/api.h" +#include "lwip/src/include/lwip/tcp.h" +#include "lwip/src/include/lwip/tcpip.h" +#include "lwip/src/include/lwip/memp.h" +#include "lwip/src/include/lwip/dhcp.h" +#include "lwip/src/include/lwip/dns.h" +#include "lwip/src/include/lwip/stats.h" +#include "lwip/src/include/lwip/init.h" +#include "lwip/src/include/ipv4/lwip/ip_frag.h" +#if ( (LWIP_VERSION) == ((1U << 24) | (3U << 16) | (2U << 8) | (LWIP_VERSION_RC)) ) +#include "lwip/src/include/netif/loopif.h" +#else +#include "lwip/src/include/ipv4/lwip/inet.h" +#include "lwip/src/include/lwip/tcp_impl.h" +#endif +#include "lwip/src/include/netif/etharp.h" +#include "lwip/src/sam/include/netif/ethernetif.h" + +#if defined(HTTP_RAW_USED) +#include "httpserver_raw/httpd.h" +#endif + +#include "lwip_test.h" + +/* Global variable containing MAC Config (hw addr, IP, GW, ...) */ +struct netif gs_net_if; + +/* Timer for calling lwIP tmr functions without system */ +typedef struct timers_info { + uint32_t timer; + uint32_t timer_interval; + void (*timer_func)(void); +} timers_info_t; + +/* LwIP tmr functions list */ +static timers_info_t gs_timers_table[] = { + {0, TCP_TMR_INTERVAL, tcp_tmr}, + {0, IP_TMR_INTERVAL, ip_reass_tmr}, +#if 0 + /* LWIP_TCP */ + {0, TCP_FAST_INTERVAL, tcp_fasttmr}, + {0, TCP_SLOW_INTERVAL, tcp_slowtmr}, +#endif + /* LWIP_ARP */ + {0, ARP_TMR_INTERVAL, etharp_tmr}, + /* LWIP_DHCP */ +#if LWIP_DHCP + {0, DHCP_COARSE_TIMER_SECS, dhcp_coarse_tmr}, + {0, DHCP_FINE_TIMER_MSECS, dhcp_fine_tmr}, +#endif +}; + +/** + * \brief Process timing functions. + */ +static void timers_update(void) +{ + static uint32_t ul_last_time; + uint32_t ul_cur_time, ul_time_diff, ul_idx_timer; + timers_info_t *p_tmr_inf; + + ul_cur_time = sys_get_ms(); + if (ul_cur_time >= ul_last_time) { + ul_time_diff = ul_cur_time - ul_last_time; + } else { + ul_time_diff = 0xFFFFFFFF - ul_last_time + ul_cur_time; + } + + if (ul_time_diff) { + ul_last_time = ul_cur_time; + for (ul_idx_timer = 0; + ul_idx_timer < (sizeof(gs_timers_table) / sizeof(timers_info_t)); + ul_idx_timer++) { + p_tmr_inf = &gs_timers_table[ul_idx_timer]; + p_tmr_inf->timer += ul_time_diff; + if (p_tmr_inf->timer > p_tmr_inf->timer_interval) { + if (p_tmr_inf->timer_func) { + p_tmr_inf->timer_func(); + } + + p_tmr_inf->timer -= p_tmr_inf->timer_interval; + } + } + } +} + +/** + * \brief Set ethernet config. + */ +//err_t ethernetif_init_(struct netif *netif){return ERR_OK;}; +//err_t ethernet_input_(struct pbuf *p, struct netif *netif){return ERR_OK;}; + +static void ethernet_configure_interface(void) +{ + struct ip_addr x_ip_addr, x_net_mask, x_gateway; + extern err_t ethernetif_init(struct netif *netif); + +#if defined(DHCP_USED) + x_ip_addr.addr = 0; + x_net_mask.addr = 0; +#else + /* Default ip addr */ + IP4_ADDR(&x_ip_addr, ETHERNET_CONF_IPADDR0, ETHERNET_CONF_IPADDR1, ETHERNET_CONF_IPADDR2, ETHERNET_CONF_IPADDR3); + + /* Default subnet mask */ + IP4_ADDR(&x_net_mask, ETHERNET_CONF_NET_MASK0, ETHERNET_CONF_NET_MASK1, ETHERNET_CONF_NET_MASK2, ETHERNET_CONF_NET_MASK3); + + /* Default gateway addr */ + IP4_ADDR(&x_gateway, ETHERNET_CONF_GATEWAY_ADDR0, ETHERNET_CONF_GATEWAY_ADDR1, ETHERNET_CONF_GATEWAY_ADDR2, ETHERNET_CONF_GATEWAY_ADDR3); +#endif + + /* Add data to netif */ + netif_add(&gs_net_if, &x_ip_addr, &x_net_mask, &x_gateway, NULL, + ethernetif_init, ethernet_input); + + /* Make it the default interface */ + netif_set_default(&gs_net_if); + + /* Setup callback function for netif status change */ + netif_set_status_callback(&gs_net_if, status_callback); + + /* Bring it up */ +#if defined(DHCP_USED) + printf("LwIP: DHCP Started"); + dhcp_start(&gs_net_if); +#else +// printf("LwIP: Static IP Address Assigned\r\n"); + netif_set_up(&gs_net_if); +#endif +} + +/** \brief Create ethernet task, for ethernet management. + * + */ +void init_ethernet(void) +{ + /* Initialize lwIP */ + lwip_init(); + + /* Set hw and IP parameters, initialize MAC too */ + ethernet_configure_interface(); + + /* Init timer service */ + sys_init_timing(); + +#if defined(HTTP_RAW_USED) + /* Bring up the web server */ + httpd_init(); +#endif +} + +/** + * \brief Status callback used to print address given by DHCP. + * + * \param netif Instance to network interface. + */ +void status_callback(struct netif *netif) +{ + int8_t c_mess[25]; + if (netif_is_up(netif)) { +// printf("Network up\r\n"); +// strcpy((char*)c_mess, "IP="); +// strcat((char*)c_mess, inet_ntoa(*(struct in_addr *)&(netif->ip_addr))); +// printf((char const*)c_mess); +// printf("-----------------\r\n"); + netif->flags |=NETIF_FLAG_LINK_UP; + } else { +// printf("Network down\r\n"); + } +} + +/**0 + * \brief Manage the Ethernet packets, if any received process them. + * After processing any packets, manage the lwIP timers. + */ +void ethernet_task(void) +{ + /* Run polling tasks */ + ethernetif_input(&gs_net_if); + + /* Run periodic tasks */ + timers_update(); +} diff --git a/network/ethernet_sam.h b/network/ethernet_sam.h new file mode 100644 index 0000000..54efa9f --- /dev/null +++ b/network/ethernet_sam.h @@ -0,0 +1,85 @@ +/** + * \file + * + * \brief Ethernet management definitions for the Standalone lwIP example. + * + * Copyright (c) 2012 Atmel Corporation. All rights reserved. + * + * \asf_license_start + * + * \page License + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of Atmel may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 4. This software may only be redistributed and used in connection with an + * Atmel microcontroller product. + * + * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * \asf_license_stop + * + */ + +#ifndef ETHERNET_SAM_H_INCLUDED +#define ETHERNET_SAM_H_INCLUDED + +#include + +/// @cond 0 +/**INDENT-OFF**/ +#ifdef __cplusplus +extern "C" { +#endif +/**INDENT-ON**/ +/// @endcond + +/** + * \brief Initialize the ethernet interface. + * + */ +void init_ethernet(void); + +/** + * \brief Status callback used to print address given by DHCP. + * + * \param netif Instance to network interface. + * + */ +void status_callback(struct netif *netif); + +/** + * \brief Manage the ethernet packets, if any received process them. + * + */ +void ethernet_task(void); + +/// @cond 0 +/**INDENT-OFF**/ +#ifdef __cplusplus +} +#endif +/**INDENT-ON**/ +/// @endcond + +#endif /* ETHERNET_SAM_H_INCLUDED */ diff --git a/network/httpserver_raw/fs.c b/network/httpserver_raw/fs.c new file mode 100644 index 0000000..6cc245c --- /dev/null +++ b/network/httpserver_raw/fs.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "../lwipopts.h" +#if defined(HTTP_RAW_USED) + +#include + +#include "lwip/src/include/lwip/def.h" +#include "fs.h" +#include "fsdata.h" + +/*-----------------------------------------------------------------------------------*/ + + +/*-----------------------------------------------------------------------------------*/ +int +fs_open(char *name, struct fs_file *file) +{ + struct fsdata_file_noconst *f; + + for(f = (struct fsdata_file_noconst *)FS_ROOT; + f != NULL; + f = (struct fsdata_file_noconst *)f->next) { + if (!strcmp(name, (char *)f->name)) { + file->data = (char *)f->data; + file->len = f->len; + return 1; + } + } + return 0; +} +/*-----------------------------------------------------------------------------------*/ + +#endif diff --git a/network/httpserver_raw/fs.h b/network/httpserver_raw/fs.h new file mode 100644 index 0000000..f5d8955 --- /dev/null +++ b/network/httpserver_raw/fs.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __FS_H__ +#define __FS_H__ + +struct fs_file { + char *data; + int len; +}; + +/* file must be allocated by caller and will be filled in + by the function. */ +int fs_open(char *name, struct fs_file *file); + +#endif /* __FS_H__ */ diff --git a/network/httpserver_raw/fsdata.c b/network/httpserver_raw/fsdata.c new file mode 100644 index 0000000..6325236 --- /dev/null +++ b/network/httpserver_raw/fsdata.c @@ -0,0 +1,339 @@ +#include "lwipopts.h" +#if defined(HTTP_RAW_USED) + +#include +#include "fsdata.h" + +static const unsigned char data_img_sics_gif[] = { + /* /img/sics.gif */ + 0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0, + 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, + 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f, + 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, + 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, + 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29, + 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, + 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0x47, + 0x49, 0x46, 0x38, 0x39, 0x61, 0x46, 00, 0x22, 00, 0xa5, + 00, 00, 0xd9, 0x2b, 0x39, 0x6a, 0x6a, 0x6a, 0xbf, 0xbf, + 0xbf, 0x93, 0x93, 0x93, 0xf, 0xf, 0xf, 0xb0, 0xb0, 0xb0, + 0xa6, 0xa6, 0xa6, 0x80, 0x80, 0x80, 0x76, 0x76, 0x76, 0x1e, + 0x1e, 0x1e, 0x9d, 0x9d, 0x9d, 0x2e, 0x2e, 0x2e, 0x49, 0x49, + 0x49, 0x54, 0x54, 0x54, 0x8a, 0x8a, 0x8a, 0x60, 0x60, 0x60, + 0xc6, 0xa6, 0x99, 0xbd, 0xb5, 0xb2, 0xc2, 0xab, 0xa1, 0xd9, + 0x41, 0x40, 0xd5, 0x67, 0x55, 0xc0, 0xb0, 0xaa, 0xd5, 0x5e, + 0x4e, 0xd6, 0x50, 0x45, 0xcc, 0x93, 0x7d, 0xc8, 0xa1, 0x90, + 0xce, 0x8b, 0x76, 0xd2, 0x7b, 0x65, 0xd1, 0x84, 0x6d, 0xc9, + 0x99, 0x86, 0x3a, 0x3a, 0x3a, 00, 00, 00, 0xb8, 0xb8, + 0xb8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2c, 00, 00, 00, 00, 0x46, + 00, 0x22, 00, 00, 0x6, 0xfe, 0x40, 0x90, 0x70, 0x48, + 0x2c, 0x1a, 0x8f, 0xc8, 0xa4, 0x72, 0xc9, 0x6c, 0x3a, 0x9f, + 0xd0, 0xa8, 0x74, 0x4a, 0xad, 0x5a, 0xaf, 0xd8, 0xac, 0x76, + 0xa9, 0x40, 0x4, 0xbe, 0x83, 0xe2, 0x60, 0x3c, 0x50, 0x20, + 0xd, 0x8e, 0x6f, 00, 0x31, 0x28, 0x1c, 0xd, 0x7, 0xb5, + 0xc3, 0x60, 0x75, 0x24, 0x3e, 0xf8, 0xfc, 0x87, 0x11, 0x6, + 0xe9, 0x3d, 0x46, 0x7, 0xb, 0x7a, 0x7a, 0x7c, 0x43, 0x6, + 0x1e, 0x84, 0x78, 0xb, 0x7, 0x6e, 0x51, 0x1, 0x8a, 0x84, + 0x8, 0x7e, 0x79, 0x80, 0x87, 0x89, 0x91, 0x7a, 0x93, 0xa, + 0x4, 0x99, 0x78, 0x96, 0x4f, 0x3, 0x9e, 0x79, 0x1, 0x94, + 0x9f, 0x43, 0x9c, 0xa3, 0xa4, 0x5, 0x77, 0xa3, 0xa0, 0x4e, + 0x98, 0x79, 0xb, 0x1e, 0x83, 0xa4, 0xa6, 0x1f, 0x96, 0x5, + 0x9d, 0xaa, 0x78, 0x1, 0x7, 0x84, 0x4, 0x1e, 0x1e, 0xbb, + 0xb8, 0x51, 0x84, 0xe, 0x43, 0x5, 0x7, 0x77, 0xa5, 0x7f, + 0x42, 0xb1, 0xb2, 0x1, 0x63, 0x8, 0xd, 0xbb, 0x1, 0xc, + 0x7a, 0xd, 0x44, 0xe, 0xd8, 0xaf, 0x4c, 0x5, 0x7a, 0x4, + 0x47, 0x7, 0x7, 0xb7, 0x80, 0xa2, 0xe1, 0x7d, 0x44, 0x5, + 0x1, 0x4, 0x1, 0xd0, 0xea, 0x87, 0x93, 0x4f, 0xe0, 0x9a, + 0x49, 0xce, 0xd8, 0x79, 0x4, 0x66, 0x20, 0x15, 0x10, 0x10, + 0x11, 0x92, 0x29, 0x80, 0xb6, 0xc0, 0x91, 0x15, 0x45, 0x1e, + 0x90, 0x19, 0x71, 0x46, 0xa8, 0x5c, 0x4, 0xe, 00, 0x22, + 0x4e, 0xe8, 0x40, 0x24, 0x9f, 0x3e, 0x4, 0x6, 0xa7, 0x58, + 0xd4, 0x93, 0xa0, 0x1c, 0x91, 0x3f, 0xe8, 0xf0, 0x88, 0x3, + 0xb1, 0x21, 0xa2, 0x49, 00, 0x19, 0x86, 0xfc, 0x52, 0x44, + 0xe0, 0x1, 0x9d, 0x29, 0x21, 0x15, 0x25, 0x50, 0xf7, 0x67, + 0x25, 0x1e, 0x6, 0xfd, 0x4e, 0x9a, 0xb4, 0x90, 0xac, 0x15, + 0xfa, 0xcb, 0x52, 0x53, 0x1e, 0x8c, 0xf2, 0xf8, 0x7, 0x92, + 0x2d, 0x8, 0x3a, 0x4d, 0x12, 0x49, 0x95, 0x49, 0xdb, 0x14, + 0x4, 0xc4, 0x14, 0x85, 0x29, 0xaa, 0xe7, 0x1, 0x8, 0xa4, + 0x49, 0x1, 0x14, 0x51, 0xe0, 0x53, 0x91, 0xd5, 0x29, 0x6, + 0x1a, 0x64, 0x2, 0xf4, 0xc7, 0x81, 0x9e, 0x5, 0x20, 0x22, + 0x64, 0xa5, 0x30, 0xae, 0xab, 0x9e, 0x97, 0x53, 0xd8, 0xb9, + 0xfd, 0x50, 0xef, 0x93, 0x2, 0x42, 0x74, 0x34, 0xe8, 0x9c, + 0x20, 0x21, 0xc9, 0x1, 0x68, 0x78, 0xe6, 0x55, 0x29, 0x20, + 0x56, 0x4f, 0x4c, 0x40, 0x51, 0x71, 0x82, 0xc0, 0x70, 0x21, + 0x22, 0x85, 0xbe, 0x4b, 0x1c, 0x44, 0x5, 0xea, 0xa4, 0x1, + 0xbf, 0x22, 0xb5, 0xf0, 0x1c, 0x6, 0x51, 0x38, 0x8f, 0xe0, + 0x22, 0xec, 0x18, 0xac, 0x39, 0x22, 0xd4, 0xd6, 0x93, 0x44, + 0x1, 0x32, 0x82, 0xc8, 0xfc, 0x61, 0xb3, 0x1, 0x45, 0xc, + 0x2e, 0x83, 0x30, 0xd0, 0xe, 0x17, 0x24, 0xf, 0x70, 0x85, + 0x94, 0xee, 0x5, 0x5, 0x53, 0x4b, 0x32, 0x1b, 0x3f, 0x98, + 0xd3, 0x1d, 0x29, 0x81, 0xb0, 0xae, 0x1e, 0x8c, 0x7e, 0x68, + 0xe0, 0x60, 0x5a, 0x54, 0x8f, 0xb0, 0x78, 0x69, 0x73, 0x6, + 0xa2, 00, 0x6b, 0x57, 0xca, 0x3d, 0x11, 0x50, 0xbd, 0x4, + 0x30, 0x4b, 0x3a, 0xd4, 0xab, 0x5f, 0x1f, 0x9b, 0x3d, 0x13, + 0x74, 0x27, 0x88, 0x3c, 0x25, 0xe0, 0x17, 0xbe, 0x7a, 0x79, + 0x45, 0xd, 0xc, 0xb0, 0x8b, 0xda, 0x90, 0xca, 0x80, 0x6, + 0x5d, 0x17, 0x60, 0x1c, 0x22, 0x4c, 0xd8, 0x57, 0x22, 0x6, + 0x20, 00, 0x98, 0x7, 0x8, 0xe4, 0x56, 0x80, 0x80, 0x1c, + 0xc5, 0xb7, 0xc5, 0x82, 0xc, 0x36, 0xe8, 0xe0, 0x83, 0x10, + 0x46, 0x28, 0xe1, 0x84, 0x14, 0x56, 0x68, 0xa1, 0x10, 0x41, + 00, 00, 0x3b, }; + +static const unsigned char data_404_html[] = { + /* /404.html */ + 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, + 0x30, 0x34, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, + 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, + 0x50, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, + 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, + 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, + 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, + 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, + 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, + 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, + 0x4c, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, + 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, + 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, + 0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, + 0x61, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20, + 0x20, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, + 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, + 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, + 0x72, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, + 0x74, 0x6f, 0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, + 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e, + 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, + 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d, + 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67, + 0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22, + 0xa, 0x9, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x3d, 0x22, 0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22, + 0x53, 0x49, 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, + 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49, + 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c, + 0x2f, 0x61, 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, + 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, + 0x22, 0x35, 0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa, + 0x9, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49, + 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68, + 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43, + 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, + 0x68, 0x32, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x50, + 0x61, 0x67, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, + 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xa, 0x9, + 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, + 0x20, 0x53, 0x6f, 0x72, 0x72, 0x79, 0x2c, 0x20, 0x74, 0x68, + 0x65, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79, 0x6f, 0x75, + 0x20, 0x61, 0x72, 0x65, 0x20, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, + 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, + 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20, + 0x20, 0x20, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, + 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, + 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, + 0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, + 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, + 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, + 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, + 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, + 0x6d, 0x6c, 0x3e, 0xa, }; + +static const unsigned char data_index_html[] = { + /* /index.html */ + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, + 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f, + 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, + 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, + 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29, + 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, + 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, + 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0x3c, + 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68, 0x65, 0x61, + 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x6c, + 0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, + 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, + 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, + 0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, + 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x3c, 0x62, + 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 0x20, + 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, + 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x72, 0x20, + 0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x74, 0x6f, + 0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, + 0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e, 0x9, 0x20, + 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, + 0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, + 0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67, 0x2f, 0x73, + 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22, 0xa, 0x9, + 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, + 0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22, 0x53, 0x49, + 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x20, 0x74, + 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49, 0x43, 0x53, + 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c, 0x2f, 0x61, + 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, + 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x35, + 0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, + 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20, + 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x77, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43, 0x50, 0x2f, + 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, + 0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, + 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 0x20, + 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79, + 0x6f, 0x75, 0x20, 0x61, 0x72, 0x65, 0x20, 0x77, 0x61, 0x74, + 0x63, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, + 0x61, 0x20, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x77, + 0x65, 0x62, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, + 0x6e, 0x67, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, + 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69, 0x67, + 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, + 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x73, 0x74, 0x61, 0x63, + 0x6b, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, + 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, + 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x6c, 0x77, + 0x49, 0x50, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, + 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, + 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x77, + 0x49, 0x50, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x6f, + 0x70, 0x65, 0x6e, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, + 0x9, 0x20, 0x20, 0x20, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x20, 0x73, 0x75, 0x69, 0x74, 0x65, 0x20, + 0x74, 0x68, 0x61, 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x6f, + 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x20, + 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x62, 0x79, + 0x20, 0x41, 0x64, 0x61, 0x6d, 0x20, 0x44, 0x75, 0x6e, 0x6b, + 0x65, 0x6c, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, + 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x53, 0x77, 0x65, 0x64, + 0x69, 0x73, 0x68, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, + 0x75, 0x74, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x43, 0x6f, 0x6d, + 0x70, 0x75, 0x74, 0x65, 0x72, 0x20, 0x53, 0x63, 0x69, 0x65, + 0x6e, 0x63, 0x65, 0x20, 0x62, 0x75, 0x74, 0x20, 0x6e, 0x6f, + 0x77, 0x20, 0x69, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x63, 0x74, 0x69, + 0x76, 0x65, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x76, 0x65, 0x6c, + 0x6f, 0x70, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x61, 0x20, + 0x74, 0x65, 0x61, 0x6d, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x65, + 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x73, 0xa, 0x9, + 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x64, 0x20, 0x77, 0x6f, 0x72, 0x6c, + 0x64, 0x2d, 0x77, 0x69, 0x64, 0x65, 0x2e, 0x20, 0x53, 0x69, + 0x6e, 0x63, 0x65, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2c, 0x20, 0x6c, 0x77, + 0x49, 0x50, 0x20, 0x68, 0x61, 0x73, 0xa, 0x9, 0x20, 0x20, + 0x20, 0x20, 0x73, 0x70, 0x75, 0x72, 0x72, 0x65, 0x64, 0x20, + 0x61, 0x20, 0x6c, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x20, 0x61, 0x6e, + 0x64, 0x20, 0x68, 0x61, 0x73, 0x20, 0x62, 0x65, 0x65, 0x6e, + 0x20, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x74, 0x6f, + 0x20, 0x73, 0x65, 0x76, 0x65, 0x72, 0x61, 0x6c, 0xa, 0x9, + 0x20, 0x20, 0x20, 0x20, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, + 0x72, 0x6d, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2e, 0x20, 0x6c, 0x77, 0x49, + 0x50, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x75, + 0x73, 0x65, 0x64, 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72, + 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x74, 0x68, + 0x20, 0x6f, 0x72, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, + 0x74, 0x20, 0x61, 0x6e, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, + 0x6c, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x4f, 0x53, 0x2e, 0xa, + 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, + 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x54, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x20, + 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x77, 0x49, + 0x50, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x69, + 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x74, 0x6f, 0x20, + 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0xa, 0x9, 0x20, 0x20, + 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x41, 0x4d, 0x20, + 0x75, 0x73, 0x61, 0x67, 0x65, 0x20, 0x77, 0x68, 0x69, 0x6c, + 0x65, 0x20, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x20, 0x68, 0x61, + 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6c, + 0x6c, 0x20, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x54, 0x43, + 0x50, 0x2e, 0x20, 0x54, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20, + 0x20, 0x20, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6c, + 0x77, 0x49, 0x50, 0x20, 0x73, 0x75, 0x69, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x75, 0x73, 0x65, + 0x20, 0x69, 0x6e, 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, + 0x65, 0x64, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, + 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x65, 0x6e, 0x73, + 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x20, 0x6b, + 0x69, 0x6c, 0x6f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x6f, + 0x66, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20, 0x52, 0x41, 0x4d, + 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x6f, 0x6f, 0x6d, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x61, 0x72, 0x6f, 0x75, 0x6e, 0x64, + 0x20, 0x34, 0x30, 0x20, 0x6b, 0x69, 0x6c, 0x6f, 0x62, 0x79, + 0x74, 0x65, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, + 0x66, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x52, 0x4f, 0x4d, + 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, + 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, + 0x20, 0x20, 0x4d, 0x6f, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, + 0x62, 0x6f, 0x75, 0x74, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x20, + 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x66, 0x6f, 0x75, + 0x6e, 0x64, 0x20, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x6c, 0x77, 0x49, 0x50, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x20, 0x61, + 0x74, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, + 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, + 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x68, 0x74, + 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, + 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, + 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x3c, 0x2f, + 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, + 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, + 0x64, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73, + 0x70, 0x3b, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, + 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, + 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, + 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0xa, }; + +const struct fsdata_file file_img_sics_gif[] = {{NULL, data_img_sics_gif, data_img_sics_gif + 14, sizeof(data_img_sics_gif) - 14}}; + +const struct fsdata_file file_404_html[] = {{file_img_sics_gif, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}}; + +const struct fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}}; + + +#endif diff --git a/network/httpserver_raw/fsdata.h b/network/httpserver_raw/fsdata.h new file mode 100644 index 0000000..6e72516 --- /dev/null +++ b/network/httpserver_raw/fsdata.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __FSDATA_H__ +#define __FSDATA_H__ + +struct fsdata_file { + const struct fsdata_file *next; + const unsigned char *name; + const unsigned char *data; + const int len; +}; + +struct fsdata_file_noconst { + struct fsdata_file *next; + unsigned char *name; + unsigned char *data; + int len; +}; + +#define FS_ROOT file_index_html +#define FS_NUMFILES 3 + +extern const struct fsdata_file file_img_sics_gif[]; +extern const struct fsdata_file file_404_html[]; +extern const struct fsdata_file file_index_html[]; + + +#endif /* __FSDATA_H__ */ diff --git a/network/httpserver_raw/httpd.c b/network/httpserver_raw/httpd.c new file mode 100644 index 0000000..3f41ca2 --- /dev/null +++ b/network/httpserver_raw/httpd.c @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwipopts.h" +#if defined(HTTP_RAW_USED) + +#include +#include "lwip/src/include/lwip/debug.h" +#include "lwip/src/include/lwip/stats.h" +#include "httpd.h" +#include "lwip/src/include/lwip/tcp.h" +#include "fs.h" + +struct http_state { + char *file; + uint16_t left; + uint8_t retries; +}; + +/*-----------------------------------------------------------------------------------*/ +static void +conn_err(void *arg, err_t err) +{ + struct http_state *hs; + + LWIP_UNUSED_ARG(err); + + hs = arg; + mem_free(hs); +} +/*-----------------------------------------------------------------------------------*/ +static void +close_conn(struct tcp_pcb *pcb, struct http_state *hs) +{ + tcp_arg(pcb, NULL); + tcp_sent(pcb, NULL); + tcp_recv(pcb, NULL); + mem_free(hs); + tcp_close(pcb); +} +/*-----------------------------------------------------------------------------------*/ +static void +send_data(struct tcp_pcb *pcb, struct http_state *hs) +{ + err_t err; + uint16_t len; + + /* We cannot send more data than space available in the send + buffer. */ + if (tcp_sndbuf(pcb) < hs->left) { + len = tcp_sndbuf(pcb); + } else { + len = hs->left; + } + + do { + err = tcp_write(pcb, hs->file, len, 0); + if (err == ERR_MEM) { + len /= 2; + } + } while (err == ERR_MEM && len > 1); + + if (err == ERR_OK) { + hs->file += len; + hs->left -= len; + /* } else { + printf("send_data: error %s len %d %d\n", lwip_strerr(err), len, tcp_sndbuf(pcb));*/ + } +} +/*-----------------------------------------------------------------------------------*/ +static err_t +http_poll(void *arg, struct tcp_pcb *pcb) +{ + struct http_state *hs; + + hs = arg; + + /* printf("Polll\n");*/ + if (hs == NULL) { + /* printf("Null, close\n");*/ + tcp_abort(pcb); + return ERR_ABRT; + } else { + ++hs->retries; + if (hs->retries == 4) { + tcp_abort(pcb); + return ERR_ABRT; + } + send_data(pcb, hs); + } + + return ERR_OK; +} +/*-----------------------------------------------------------------------------------*/ +static err_t +http_sent(void *arg, struct tcp_pcb *pcb, uint16_t len) +{ + struct http_state *hs; + + LWIP_UNUSED_ARG(len); + + hs = arg; + + hs->retries = 0; + + if (hs->left > 0) { + send_data(pcb, hs); + } else { + close_conn(pcb, hs); + } + + return ERR_OK; +} +/*-----------------------------------------------------------------------------------*/ +static err_t +http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) +{ + int i; + char *data; + struct fs_file file; + struct http_state *hs; + + hs = arg; + + if (err == ERR_OK && p != NULL) { + + /* Inform TCP that we have taken the data. */ + tcp_recved(pcb, p->tot_len); + + if (hs->file == NULL) { + data = p->payload; + + if (strncmp(data, "GET ", 4) == 0) { + for(i = 0; i < 40; i++) { + if (((char *)data + 4)[i] == ' ' || + ((char *)data + 4)[i] == '\r' || + ((char *)data + 4)[i] == '\n') { + ((char *)data + 4)[i] = 0; + } + } + + if (*(char *)(data + 4) == '/' && + *(char *)(data + 5) == 0) { + fs_open("/index.html", &file); + } else if (!fs_open((char *)data + 4, &file)) { + fs_open("/404.html", &file); + } + + hs->file = file.data; + hs->left = file.len; + /* printf("data %p len %ld\n", hs->file, hs->left);*/ + + pbuf_free(p); + send_data(pcb, hs); + + /* Tell TCP that we wish be to informed of data that has been + successfully sent by a call to the http_sent() function. */ + tcp_sent(pcb, http_sent); + } else { + pbuf_free(p); + close_conn(pcb, hs); + } + } else { + pbuf_free(p); + } + } + + if (err == ERR_OK && p == NULL) { + close_conn(pcb, hs); + } + return ERR_OK; +} +/*-----------------------------------------------------------------------------------*/ +static err_t +http_accept(void *arg, struct tcp_pcb *pcb, err_t err) +{ + struct http_state *hs; + + LWIP_UNUSED_ARG(arg); + LWIP_UNUSED_ARG(err); + + tcp_setprio(pcb, TCP_PRIO_MIN); + + /* Allocate memory for the structure that holds the state of the + connection. */ + hs = (struct http_state *)mem_malloc(sizeof(struct http_state)); + + if (hs == NULL) { + //printf("http_accept: Out of memory\n"); + return ERR_MEM; + } + + /* Initialize the structure. */ + hs->file = NULL; + hs->left = 0; + hs->retries = 0; + + /* Tell TCP that this is the structure we wish to be passed for our + callbacks. */ + tcp_arg(pcb, hs); + + /* Tell TCP that we wish to be informed of incoming data by a call + to the http_recv() function. */ + tcp_recv(pcb, http_recv); + + tcp_err(pcb, conn_err); + + tcp_poll(pcb, http_poll, 4); + return ERR_OK; +} +/*-----------------------------------------------------------------------------------*/ +void +httpd_init(void) +{ + struct tcp_pcb *pcb; + + pcb = tcp_new(); + tcp_bind(pcb, IP_ADDR_ANY, 80); + pcb = tcp_listen(pcb); + tcp_accept(pcb, http_accept); +} +/*-----------------------------------------------------------------------------------*/ + +#endif + diff --git a/network/httpserver_raw/httpd.h b/network/httpserver_raw/httpd.h new file mode 100644 index 0000000..b819414 --- /dev/null +++ b/network/httpserver_raw/httpd.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __HTTPD_H__ +#define __HTTPD_H__ + +void httpd_init(void); + +#endif /* __HTTPD_H__ */ diff --git a/network/lwip_test.h b/network/lwip_test.h new file mode 100644 index 0000000..7e55bf7 --- /dev/null +++ b/network/lwip_test.h @@ -0,0 +1,33 @@ +// Only modify this file to include +// - function definitions (prototypes) +// - include files +// - extern variable definitions +// In the appropriate section + +#ifndef lwip_test_H_ +#define lwip_test_H_ +#include "Arduino.h" +//add your includes for the project lwip_test here +#include "SamNonDuePin.h" +#include "lwip/src/include/lwip/netif.h" +#include +#include "ethernet_sam.h" +#include "timer_mgt_sam.h" +#include +#undef printf + +//end of add your includes here +#ifdef __cplusplus +extern "C" { +#endif +void loop(); +void setup(); +#ifdef __cplusplus +} // extern "C" +#endif + +//add your function definitions for the project lwip_test here +void printf(char *fmt, ... ); + +//Do not add code below this line +#endif /* lwip_test_H_ */ diff --git a/network/lwipopts.h b/network/lwipopts.h new file mode 100644 index 0000000..46a1c15 --- /dev/null +++ b/network/lwipopts.h @@ -0,0 +1,253 @@ +/***************************************************************************** + * + * \file + * + * \brief lwIP configuration. + * + * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. + * + * \asf_license_start + * + * \page License + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of Atmel may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 4. This software may only be redistributed and used in connection with an + * Atmel microcontroller product. + * + * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * \asf_license_stop + * + *****************************************************************************/ + + + +#ifndef __LWIPOPTS_H__ +#define __LWIPOPTS_H__ + +//#define LWIP_DEBUG + +/* Include user defined options first */ + #include "conf_eth.h" + +#include "lwip/src/include/lwip/debug.h" + +/* ---------- System options ---------- */ +/* Specify NO_SYS because we are not using an RTOS */ +#define NO_SYS 1 +#define LWIP_RAW 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 + +/* These options can be configured by the user in the standalone demo default demo */ +#define HTTP_RAW_USED +// #undef HTTP_RAW_USED +//#define DHCP_USED + #undef DHCP_USED + + +/* These are not available when using "NO_SYS" */ +#define LWIP_NETCONN 0 +#define LWIP_SOCKET 0 + + +/* ---------- Memory options ---------- */ + +/* These two control is reclaimer functions should be compiled + in. Should always be turned on (1). */ +#define MEM_RECLAIM 1 +#define MEMP_RECLAIM 1 + +/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which + lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 + byte alignment -> define MEM_ALIGNMENT to 2. */ +#define MEM_ALIGNMENT 4 + +/* MEM_SIZE: the size of the heap memory. If the application will send +a lot of data that needs to be copied, this should be set high. */ +#define MEM_SIZE 3 * 1024 + +/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application + sends a lot of data out of ROM (or other static memory), this + should be set high. */ +#define MEMP_NUM_PBUF 12 + +/* Number of raw connection PCBs */ +#define MEMP_NUM_RAW_PCB 2 + +/* ---------- UDP options ---------- */ +#define LWIP_UDP 1 +#define UDP_TTL 255 +/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + per active UDP "connection". */ +#define MEMP_NUM_UDP_PCB 4 + +/* MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections. */ +#define MEMP_NUM_TCP_PCB 2 +/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. */ +#define MEMP_NUM_TCP_PCB_LISTEN 1 +/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */ +#define MEMP_NUM_TCP_SEG 13 //changed from 9 to pass LWIP sanity checks +/* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts. */ +#define MEMP_NUM_SYS_TIMEOUT 6 + +/* The following four are used only with the sequential API and can be + set to 0 if the application only will use the raw API. */ +/* MEMP_NUM_NETBUF: the number of struct netbufs. */ +#define MEMP_NUM_NETBUF 0 +/* MEMP_NUM_NETCONN: the number of struct netconns. */ +#define MEMP_NUM_NETCONN 0 + +/* ---------- Pbuf options ---------- */ +/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ +#define PBUF_POOL_SIZE 6 +/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ +#define PBUF_POOL_BUFSIZE 512 + +/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure + * alignment of payload after that header. Since the header is 14 bytes long, + * without this padding e.g. addresses in the IP header will not be aligned + * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. + */ +#define ETH_PAD_SIZE 2 + +/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a + link level header. */ +#define PBUF_LINK_HLEN (16 + ETH_PAD_SIZE) + + +/* ---------- TCP options ---------- */ +#define LWIP_TCP 1 +#define TCP_TTL 255 +/* TCP receive window. */ +#define TCP_WND 1500 +/* Controls if TCP should queue segments that arrive out of + order. Define to 0 if your device is low on memory. */ +#define TCP_QUEUE_OOSEQ 1 +/* TCP Maximum segment size. */ +#define TCP_MSS 1500 +/* TCP sender buffer space (bytes). */ +#define TCP_SND_BUF 3000 //changed from 2150 to pass LWIP sanity checks +/* TCP sender buffer space (pbufs). This must be at least = 2 * + TCP_SND_BUF/TCP_MSS for things to work. */ +#define TCP_SND_QUEUELEN ((6 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) +/* Maximum number of retransmissions of data segments. */ +// #define TCP_MAXRTX 12 +/* Maximum number of retransmissions of SYN segments. */ +// #define TCP_SYNMAXRTX 4 + + +/* ---------- ARP options ---------- */ +#define ARP_TABLE_SIZE 10 +#define ARP_QUEUEING 0 + + +/* ---------- IP options ---------- */ +/* Define IP_FORWARD to 1 if you wish to have the ability to forward + IP packets across network interfaces. If you are going to run lwIP + on a device with only one network interface, define this to 0. */ +#define IP_FORWARD 0 +/* If defined to 1, IP options are allowed (but not parsed). If + defined to 0, all packets with IP options are dropped. */ +#define IP_OPTIONS 1 + + +/* ---------- ICMP options ---------- */ +#define ICMP_TTL 255 + + +#if defined(DHCP_USED) +/* ---------- DHCP options ---------- */ +/* Define LWIP_DHCP to 1 if you want DHCP configuration of + interfaces. DHCP is not implemented in lwIP 0.5.1, however, so + turning this on does currently not work. */ +#define LWIP_DHCP 1 + +/* 1 if you want to do an ARP check on the offered address + (recommended). */ + #define DHCP_DOES_ARP_CHECK 1 +#endif + +/* ---------- Statistics options ---------- */ +#define LWIP_STATS 1 +#define LWIP_STATS_DISPLAY 1 + +#if LWIP_STATS +#define LINK_STATS 1 +#define IP_STATS 1 +#define ICMP_STATS 1 +#define UDP_STATS 1 +#define TCP_STATS 1 +#define MEM_STATS 1 +#define MEMP_STATS 1 +#define PBUF_STATS 1 +#define SYS_STATS 1 +#endif /* STATS */ + + +/* ---------- Lwip Debug options ---------- */ +/* Define default values for unconfigured parameters. */ +// 1 == To suppress some errors for now (no debug output) +#define LWIP_NOASSERT 0 + + +#define DBG_TYPES_ON 0xff +#define ETHARP_DEBUG LWIP_DBG_ON +#define NETIF_DEBUG LWIP_DBG_ON +#define PBUF_DEBUG LWIP_DBG_ON +#define API_LIB_DEBUG LWIP_DBG_ON +#define API_MSG_DEBUG LWIP_DBG_ON +#define SOCKETS_DEBUG LWIP_DBG_ON +#define ICMP_DEBUG LWIP_DBG_ON +#define INET_DEBUG LWIP_DBG_ON +#define IP_DEBUG LWIP_DBG_ON +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_ON +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL + + +// \note For a list of all possible lwIP configurations, check http://lwip.wikia.com/wiki/Lwipopts.h + +/** EMAC PHY address */ +#define BOARD_EMAC_PHY_ADDR 2 +/*! EMAC RMII mode */ +#define BOARD_EMAC_MODE_RMII 1 + +/**/ + +#endif /* __LWIPOPTS_H__ */ diff --git a/network/timer_mgt_sam.c b/network/timer_mgt_sam.c new file mode 100644 index 0000000..007b220 --- /dev/null +++ b/network/timer_mgt_sam.c @@ -0,0 +1,147 @@ +/** + * \file + * + * \brief Timer management for lwIP example. + * + * Copyright (c) 2012 Atmel Corporation. All rights reserved. + * + * \asf_license_start + * + * \page License + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of Atmel may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 4. This software may only be redistributed and used in connection with an + * Atmel microcontroller product. + * + * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * \asf_license_stop + * + */ + +//#include "board.h" +#include "timer_mgt_sam.h" +#include "include/tc.h" +#include "include/pmc.h" +//#include "sysclk.h" +#include "lwip/src/include/lwip/sys.h" +#include "lwip_test.h" + +volatile int ledState; +/** Clock tick count */ +static volatile uint32_t gs_ul_clk_tick; + +/** + * Interrupt handler for TC0 interrupt. + */ +//void TC0_Handler(void) +//{ + /* Remove warnings */ +// volatile uint32_t ul_dummy; + + /* Clear status bit to acknowledge interrupt */ +// ul_dummy = TC0->TC_CHANNEL[0].TC_SR; + + /* Increase tick */ +// gs_ul_clk_tick++; +//} + +void TC4_Handler() +{ + // You must do TC_GetStatus to "accept" interrupt + // As parameters use the first two parameters used in startTimer (TC1, 0 in this case) + TC_GetStatus(TC1, 1); + + /* Increase tick */ + gs_ul_clk_tick++; + + ledState = !ledState; +} + +/** + * \brief Initialize for timing operation. + */ +void sys_init_timing(void) +{ + uint32_t ul_div; + uint32_t ul_tcclks; + + /* Clear tick value */ + gs_ul_clk_tick = 0; + + startTimer(TC1,1,TC4_IRQn,4); + +} +// Start timer. Parameters are: + + // TC1 : timer counter. Can be TC0, TC1 or TC2 + // 0 : channel. Can be 0, 1 or 2 + // TC3_IRQn: irq number. See table. + // 40 : frequency (in Hz) + // The interrupt service routine is TC3_Handler. See table. +void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) { + pmc_set_writeprotect(false); + pmc_enable_periph_clk((uint32_t)irq); + TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4); + uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above + TC_SetRA(tc, channel, rc/2); //50% high, 50% low + TC_SetRC(tc, channel, rc); + TC_Start(tc, channel); + tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS; + tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS; + NVIC_EnableIRQ(irq); +} +// Paramters table: +// TC0, 0, TC0_IRQn => TC0_Handler() +// TC0, 1, TC1_IRQn => TC1_Handler() +// TC0, 2, TC2_IRQn => TC2_Handler() +// TC1, 0, TC3_IRQn => TC3_Handler() +// TC1, 1, TC4_IRQn => TC4_Handler() +// TC1, 2, TC5_IRQn => TC5_Handler() +// TC2, 0, TC6_IRQn => TC6_Handler() +// TC2, 1, TC7_IRQn => TC7_Handler() +// TC2, 2, TC8_IRQn => TC8_Handler() + + +/** + * \brief Read for clock time (ms). + */ +uint32_t sys_get_ms(void) +{ + return gs_ul_clk_tick; +} + +#if (THIRDPARTY_LWIP_VERSION != 132) + +/* See lwip/sys.h for more information + Returns number of milliseconds expired + since lwip is initialized +*/ +u32_t sys_now(void) +{ + return (sys_get_ms()); +} + +#endif diff --git a/network/timer_mgt_sam.h b/network/timer_mgt_sam.h new file mode 100644 index 0000000..7ffd3b9 --- /dev/null +++ b/network/timer_mgt_sam.h @@ -0,0 +1,57 @@ +/** + * \file + * + * \brief Timer management definitions for lwIP example. + * + * Copyright (c) 2012 Atmel Corporation. All rights reserved. + * + * \asf_license_start + * + * \page License + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of Atmel may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 4. This software may only be redistributed and used in connection with an + * Atmel microcontroller product. + * + * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * \asf_license_stop + * + */ + +#ifndef TIMER_MGT_SAM_H_INCLUDED +#define TIMER_MGT_SAM_H_INCLUDED + +#include "Arduino.h" + +#define CLOCK_CONF_SECOND 1000 + +void sys_init_timing(void); +extern uint32_t sys_get_ms(void); +void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency); + +extern volatile int ledState; + +#endif /* TIMER_MGT_SAM_H_INCLUDED */