diff --git a/.travis.yml b/.travis.yml
index f5fdc0af..8b137891 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,53 +1 @@
-sudo: false
-language: bash
-
-os:
- - linux
-
-before_install:
- - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
-
-before_script:
- - "export DISPLAY=:99.0"
- - sleep 3 # give xvfb some time to start
- - wget http://downloads.arduino.cc/arduino-1.8.4-linux64.tar.xz
- - tar xf arduino-1.8.4-linux64.tar.xz
- - mv arduino-1.8.4 $HOME/arduino_ide
- - cd $HOME/arduino_ide/hardware
- - mkdir esp8266com
- - cd esp8266com
- - git clone https://github.com/esp8266/Arduino.git esp8266
- - cd esp8266/tools
- - python get.py
- - cd ..
- - echo 'build.flash_ld=eagle.flash.4m.ld' >> platform.txt
- - echo 'build.flash_freq=40' >> platform.txt
- - echo 'build.flash_size=4M' >> platform.txt
- - echo 'build.flash_mode=dio' >> platform.txt
- - echo 'build.f_cpu=160000000L' >> platform.txt
- - sed -i "s/generic.build.f_cpu=80000000L/generic.build.f_cpu=160000000L/g" ./boards.txt
- - cd $HOME/arduino_ide/hardware
- - mkdir esp32
- - cd esp32
- - git clone https://github.com/espressif/arduino-esp32.git esp32
- - cd esp32/tools
- - python get.py
- - cd ..
- - echo 'build.flash_freq=40m' >> platform.txt
-
-
-script:
- - cd $TRAVIS_BUILD_DIR
- - source command.sh
- - export PATH="$HOME/arduino_ide:$PATH"
- - arduino --board esp8266com:esp8266:generic --save-prefs
- - arduino --get-pref sketchbook.path
- - build_sketch esp3d/esp3d.ino
- - arduino --board esp32:esp32:esp32 --save-prefs
- - build_sketch esp3d/esp3d.ino
-
-notifications:
- email:
- on_success: change
- on_failure: change
diff --git a/README.md b/README.md
index 7d808d8f..be97a8fc 100644
--- a/README.md
+++ b/README.md
@@ -1,137 +1,3 @@
-# ESP3D[](https://codeclimate.com/github/luc-github/ESP3D)
+# ESP3D 3.0
-Firmware for ESP8266/ESP8285 and ESP32 used with 3D printer using [ESP8266 core version](https://github.com/esp8266/Arduino) and [ESP32 core version](https://github.com/espressif/arduino-esp32)
-
-This firmware allows not only to have a cheap bridge between Wifi and serial, but also to have a web UI to configure wifi, to monitor 3D printer and even control it, and to make things easy,
-UI is fully customizable without reflashing FW.
-
-Firmware should work with any 3D printer firmware (repetier/marlin/smoothieware using GCODE) if serial connection has a correct setup.
-I currently use it with my personnal flavor of [repetier for Due based boards](https://github.com/luc-github/Repetier-Firmware-0.92).
-
-The web interface files are present in data directory but UI has it's own repository [ESP3D-WEBUI](https://github.com/luc-github/ESP3D-WEBUI).
-* be aware ESP3D-WEBUI is for firmware 0.9.99 minimum - previous released version use tpl files which are no more used.
-
-Stable version (ESP8266 only):
-Arduino ide 1.6.5 with stable [2.0.0](http://arduino.esp8266.com/versions/2.0.0/package_esp8266com_index.json) from ESP8266, please use https://github.com/luc-github/ESP3D/releases/tag/v0.5.1
-Arduino ide 1.6.8 with stable [2.2.0](http://arduino.esp8266.com/versions/2.2.0/package_esp8266com_index.json) from ESP8266, please use https://github.com/luc-github/ESP3D/releases/tag/v0.6.2
-Arduino ide 1.8.5 with stable [2.4.0](http://arduino.esp8266.com/versions/2.4.0/package_esp8266com_index.json) from ESP8266, please use https://github.com/luc-github/ESP3D/releases/tag/1.0 [](https://travis-ci.org/luc-github/ESP3D)
-
-[Development version for 2.0 (2.0 branch)](https://github.com/luc-github/ESP3D/tree/2.0) & [ESP-WEBUI (2.0 branch)](https://github.com/luc-github/ESP3D-WEBUI/tree/2.0):
-Arduino ide 1.8.5 with git version from ESP8266 or ESP32 for 100% support of ESP32 : [](https://travis-ci.org/luc-github/ESP3D)
-
-[All releases](https://github.com/luc-github/ESP3D/wiki)
-
-:+1:Thanks
-* to @disneysw for bringing this module idea
-* to @lkarlslund for suggestion about independent reset using GPIO2
-* to Roy Cortes from http://www.panucatt.com for supporting and pushing me implementing great features
-* to all contributors, feedbacks owners and donations.
-
-## Donate
-Every support is welcome: [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y8FFE7NA4LJWQ)
-Especially if need to buy new modules for testing.
-
-## Features
-* Serial/Wifi bridge using configurable port 8888, here to enable/disable [TCP_IP_DATA_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* Use GPIO2 to ground to reset all settings in hard way - 2-6 sec after boot / not before!! Set GPIO2 to ground before boot change boot mode and go to special boot that do not reach FW. Currently boot take 10 sec - giving 8 seconds to connect GPIO2 to GND and do an hard recovery for settings, here to enable/disable [RECOVERY_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
-* Complete configuration by web browser (Station or Access point) or by Serial commands
-* Authentication for sensitive pages, here to enable/disable [AUTHENTICATION_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* Update firmware by web browser, here to enable/disable [WEB_UPDATE_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* Control ESP module using commands on serial or data port, here to enable/disable [SERIAL_COMMAND_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* UI fully constomizable without reflashing FW using html templates, [keywords](https://raw.githubusercontent.com/luc-github/ESP3D/master/docs/keywords.txt) and html files/images
-* Captive portal in Access point mode which redirect all unknow call to main page, here to enable/disable [CAPTIVE_PORTAL_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* mDNS which allows to key the name defined in web browser and connect only with bonjour installed on computer, here to enable/disable [MDNS_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* SSDP, this feature is a discovery protocol, supported on Windows out of the box, here to enable/disable [SSDP_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* Printer monitoring / control (temperatures/speed/jog/list SDCard content/launch,pause or stop a print/etc...), here to enable/disable [MONITORING_FEATURE/INFO_MSG_FEATURE/ERROR_MSG_FEATURE/STATUS_MSG_FEATURE](https://github.com/luc-github/ESP3D/blob/master/esp3d/config.h)
-* Fail safe mode (Access point)is enabled if cannot connect to defined station at boot.
-* The web ui add even more feature : https://github.com/luc-github/ESP3D-WEBUI/blob/master/README.md#features
-
-
-## Web configuration
-*Wifi Mode : Access point / Client station
-*IP Generation: DHCP/Static IP
-*IP/MASK/GATEWAY for static data
-*Baud Rate for serial (supported : 9600, 19200, 38400, 57600, 115200, 230400, 250000)
-*web port and data port
-
-
-## Default Configuration
-Default Settings:
-AP:ESP8266
-PW:12345678
-Authentification: WPA
-Mode: g (n is not supported by AP, just by STA)
-channel: 11
-AP: visible
-Sleep Mode: Modem
-IP Mode: Static IP
-IP: 192.168.0.1
-Mask: 255.255.255.0
-GW:192.168.0.1
-Baud rate: 115200
-Web port:80
-Data port: 8888
-Web Page refresh: 3 secondes
-User: admin
-Password: admin
-User:user
-Password: user
-
-
-
-## Direct commands:
-Check wiki : https://github.com/luc-github/ESP3D/wiki/Direct-ESP3D-commands
-
-## Installation
-1. Please follow installation of the ESP core you want to use : [ESP8266 core version](https://github.com/esp8266/Arduino) or [ESP32 core version](https://github.com/espressif/arduino-esp32)
-2. Add missing libraries if you target ESP32 present in libraries directory
-* DNSServer (from https://github.com/bbx10/DNSServer_tng)
-* WebServer (from https://github.com/bbx10/WebServer_tng)
-* NetBIOS and SSDP are currently disabled for ESP32 as not yet supported
-3. Compile project (ESP3D.ino) according target: ESP8266 board or ESP32 board, please review config.h to enable disable a feature, by default athenticatio is disabled and all others are enabled.
-* for ESP8266 set CPU freq to 160MHz for better (https://github.com/luc-github/ESP3D/wiki/Install-Instructions)
-4. Upload the data content on ESP3D file system
-* Using SPIFFS uploader, this plugin and install instructions is available on each ESP core - please refere to it
-* Using embedded uploader (you may need to format SPIFFS using : [ESP710]FORMAT on ESP8266 first)
-if embedded uploader does not show up you can force it ti display using : http://your_IP_address?forcefallback=yes
-
-
-## Update
-* Generate a binary using the export binary menu from Arduino IDE and upload it using ESP-WEBUI or embedded interface
-
-
:warning:Do not flash your Printer fw with ESP connected - it bring troubles, at least on DaVinci
-
-## Contribution/customization
-* To style the code before pushing PR please use [astyle --style=otbs *.h *.cpp *.ino](http://astyle.sourceforge.net/)
-* The embedded page is created using nodejs then gulp to generate a compressed html page (tool.html.gz), all necessary modules can be installed using the install.bat file content, then it is included using bin2c (https://sourceforge.net/projects/bin2c/) to generate the h file used to create the file nofile.h, update the array and size according new out.h.
-* The current UI is located [here](https://github.com/luc-github/ESP3D-WEBUI)
-* An optional UI is under development using old repetier UI - check [UI\repetier\testui.htm] (https://github.com/luc-github/ESP3D/blob/master/UI/repetier/testui.htm) file
-
-Feedback/suggestion/discussions are always welcome
-
-## Need more information about supported boards or wiring ?
-[Check the wiki](https://github.com/luc-github/ESP3D/wiki)
-
-## :question:Any question ?
-Check [Wiki](https://github.com/luc-github/ESP3D/wiki/Install-Instructions) or [](https://gitter.im/luc-github/ESP3D?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
-## :exclamation:Any issue/feedback ?
-Check [Wiki](https://github.com/luc-github/ESP3D/wiki/Install-Instructions) and [FAQ](https://github.com/luc-github/ESP3D/issues?utf8=%E2%9C%93&q=label%3AFAQ+) or [submit ticket](https://github.com/luc-github/ESP3D/issues)
-
-## ESP3D is used by :
-* Custom version is used on azteeg mini wifi : http://www.panucatt.com/azteeg_X5_mini_reprap_3d_printer_controller_p/ax5mini.htm
-* GRBL_Esp32 a GRBL port on ESP32 done by @bdring - https://github.com/bdring/Grbl_Esp32
-[](https://www.youtube.com/watch?v=7vtWNn9jyDs)
-* Marlin_ESP32 a Marlin port on ESP32 done by @simon-jouet is under sync : https://github.com/luc-github/Marlin/tree/eps32_webui
-* More to come...
-
-If you use ESP3D on your product, drop me a message so I can link your product page here.
-
-
-
-## TODO/On going :
--- Version 2.X
--- Close open topics
--- Do testing (a lot)
--- UI Improvement
--- ESP3D V2
+
\n\n\n\n";
-const char CONTENT_TYPE_HTML [] PROGMEM ="text/html";
-
-void handle_web_interface_root()
-{
- String path = "/index.html";
- String contentType = web_interface->getContentType(path);
- String pathWithGz = path + ".gz";
- //if have a index.html or gzip version this is default root page
- if((SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) && !web_interface->web_server.hasArg("fallback") && web_interface->web_server.arg("forcefallback")!="yes") {
- if(SPIFFS.exists(pathWithGz)) {
- path = pathWithGz;
- }
- FS_FILE file = SPIFFS.open(path, SPIFFS_FILE_READ);
- web_interface->web_server.streamFile(file, contentType);
- file.close();
- return;
- }
- //if no lets launch the default content
- web_interface->web_server.sendHeader("Content-Encoding", "gzip");
- web_interface->web_server.send_P(200,CONTENT_TYPE_HTML,PAGE_NOFILES,PAGE_NOFILES_SIZE);
-}
-
-//concat several catched informations temperatures/position/status/flow/speed
-void handle_web_interface_status()
-{
- // static const char NO_TEMP_LINE[] PROGMEM = "\"temperature\":\"0\",\"target\":\"0\",\"active\":\"0\"";
- //we do not care if need authentication - just reset counter
- web_interface->is_authenticated();
- //int tagpos,tagpos2;
- String buffer2send;
- String value;
- //start JSON answer
- buffer2send="{";
-#ifdef INFO_MSG_FEATURE
- //information
- buffer2send.concat(F("\"InformationMsg\":["));
-
- for (int i=0; iinfo_msg.size(); i++) {
- if (i>0) {
- buffer2send+=",";
- }
- buffer2send+="{\"line\":\"";
- buffer2send+=web_interface->info_msg.get(i);
- buffer2send+="\"}";
- }
- buffer2send+="],";
-#endif
-#ifdef ERROR_MSG_FEATURE
- //Error
- buffer2send.concat(F("\"ErrorMsg\":["));
- for (int i=0; ierror_msg.size(); i++) {
- if (i>0) {
- buffer2send+=",";
- }
- buffer2send+="{\"line\":\"";
- buffer2send+=web_interface->error_msg.get(i);
- buffer2send+="\"}";
- }
- buffer2send+="],";
-#endif
-#ifdef STATUS_MSG_FEATURE
- //Status
- buffer2send.concat(F("\"StatusMsg\":["));
-
- for (int i=0; istatus_msg.size(); i++) {
- if (i>0) {
- buffer2send+=",";
- }
- buffer2send+="{\"line\":\"";
- buffer2send+=web_interface->status_msg.get(i);
- buffer2send+="\"}";
- }
- buffer2send+="],";
-#endif
- //status color
- buffer2send+="\"status\":\""+value +"\"";
- buffer2send+="}";
- web_interface->web_server.sendHeader("Cache-Control", "no-cache");
- web_interface->web_server.send(200, "application/json",buffer2send);
-}
-
-//SPIFFS files uploader handle
-void SPIFFSFileupload()
-{
-#ifdef DEBUG_PERFORMANCE
- static uint32_t startupload;
- static uint32_t write_time;
- static size_t filesize;
-#endif
- //get authentication status
- level_authenticate_type auth_level= web_interface->is_authenticated();
- //Guest cannot upload
- if (auth_level == LEVEL_GUEST) {
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- ESP_SERIAL_OUT.println("M117 Error ESP upload");
-#ifdef ARDUINO_ARCH_ESP8266
- web_interface->web_server.client().stopAll();
-#else
- web_interface->web_server.client().stop();
-#endif
- return;
- }
-
- static String filename;
- //get current file ID
- HTTPUpload& upload = (web_interface->web_server).upload();
- //Upload start
- //**************
- if(upload.status == UPLOAD_FILE_START) {
-#ifdef DEBUG_PERFORMANCE
- startupload = millis();
- write_time = 0;
- filesize = 0;
-#endif
- //according User or Admin the root is different as user is isolate to /user when admin has full access
- if(auth_level == LEVEL_ADMIN) {
- filename = upload.filename;
- } else {
- filename = "/user" + upload.filename;
- }
- ESP_SERIAL_OUT.println("M117 Start ESP upload");
- //create file
- web_interface->fsUploadFile = SPIFFS.open(filename, SPIFFS_FILE_WRITE);
- //check If creation succeed
- if (web_interface->fsUploadFile) {
- //if yes upload is started
- web_interface->_upload_status= UPLOAD_STATUS_ONGOING;
- } else {
- //if no set cancel flag
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- ESP_SERIAL_OUT.println("M117 Error ESP create");
-#ifdef ARDUINO_ARCH_ESP8266
- web_interface->web_server.client().stopAll();
-#else
- web_interface->web_server.client().stop();
-#endif
- }
- //Upload write
- //**************
- } else if(upload.status == UPLOAD_FILE_WRITE) {
- //check if file is available and no error
- if(web_interface->fsUploadFile && web_interface->_upload_status == UPLOAD_STATUS_ONGOING) {
-#ifdef DEBUG_PERFORMANCE
- filesize+=upload.currentSize;
- uint32_t startwrite = millis();
-#endif
- //no error so write post date
- web_interface->fsUploadFile.write(upload.buf, upload.currentSize);
-#ifdef DEBUG_PERFORMANCE
- write_time += (millis()-startwrite);
-#endif
- } else {
- //we have a problem set flag UPLOAD_STATUS_CANCELLED
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
-#ifdef ARDUINO_ARCH_ESP8266
- web_interface->web_server.client().stopAll();
-#else
- web_interface->web_server.client().stop();
-#endif
- ESP_SERIAL_OUT.println("M117 Error ESP write");
- }
- //Upload end
- //**************
- } else if(upload.status == UPLOAD_FILE_END) {
-#ifdef DEBUG_PERFORMANCE
- uint32_t endupload = millis();
- DEBUG_PERF_VARIABLE.add(String(endupload-startupload).c_str());
- DEBUG_PERF_VARIABLE.add(String(write_time).c_str());
- DEBUG_PERF_VARIABLE.add(String(filesize).c_str());
-#endif
- ESP_SERIAL_OUT.println("M117 End ESP upload");
- //check if file is still open
- if(web_interface->fsUploadFile) {
- //close it
- web_interface->fsUploadFile.close();
- web_interface->_upload_status=UPLOAD_STATUS_SUCCESSFUL;
- } else {
- //we have a problem set flag UPLOAD_STATUS_CANCELLED
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
-#ifdef ARDUINO_ARCH_ESP8266
- web_interface->web_server.client().stopAll();
-#else
- web_interface->web_server.client().stop();
-#endif
- SPIFFS.remove(filename);
- ESP_SERIAL_OUT.println("M117 Error ESP close");
- }
- //Upload cancelled
- //**************
- } else {
- ESP_SERIAL_OUT.println("M117 Error ESP close");
- return;
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- SPIFFS.remove(filename);
- ESP_SERIAL_OUT.println("M117 Error ESP upload");
- }
- delay(0);
-}
-
-#define NB_RETRY 5
-#define MAX_RESEND_BUFFER 128
-//SD file upload by serial
-void SDFile_serial_upload()
-{
- static char buffer_line[MAX_RESEND_BUFFER]; //if need to resend
- static char previous = 0;
- static int buffer_size;
- static bool com_error = false;
- static bool is_comment = false;
- bool client_closed = false;
- static String filename;
- String response;
- //Guest cannot upload - only admin and user
- if(web_interface->is_authenticated() == LEVEL_GUEST) {
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- ESP_SERIAL_OUT.println("M117 SD upload rejected");
- LOG("SD upload rejected\r\n");
- if (!client_closed){
- //web_interface->web_server.client().stopAll();
- LOG("Need to stop");
- client_closed = true;
- }
- return;
- }
-#ifdef DEBUG_PERFORMANCE
- static uint32_t startupload;
- static uint32_t write_time;
- static size_t filesize;
-#endif
- //retrieve current file id
- HTTPUpload& upload = (web_interface->web_server).upload();
- //Upload start
- //**************
- if(upload.status == UPLOAD_FILE_START) {
- //need to lock serial out to avoid garbage in file
- (web_interface->blockserial) = true;
- //init flags
- buffer_size=0;
- com_error = false;
- is_comment = false;
- previous = 0;
- web_interface->_upload_status= UPLOAD_STATUS_ONGOING;
- ESP_SERIAL_OUT.println("M117 Uploading...");
- ESP_SERIAL_OUT.flush();
-#ifdef DEBUG_PERFORMANCE
- startupload = millis();
- write_time = 0;
- filesize = 0;
-#endif
- LOG("Clear Serial\r\n");
- if(ESP_SERIAL_OUT.available()) {
- //get size of buffer
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- //read buffer
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- //convert buffer to zero end array
- sbuf[len]='\0';
- //use string because easier to handle
- response = (const char*)sbuf;
- LOG(response);
- LOG("\r\n");
- }
- //command to pritnter to start print
- String command = "M28 " + upload.filename;
- LOG(command);
- LOG("\r\n");
- ESP_SERIAL_OUT.println(command);
- ESP_SERIAL_OUT.flush();
- filename = upload.filename;
- //now need to purge all serial data
- //let's sleep 1s
- //delay(1000);
- for (int retry=0; retry < 400; retry++) { //time out is 5x400ms = 2000ms
- //if there is something in serial buffer
- if(ESP_SERIAL_OUT.available()) {
- //get size of buffer
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- //read buffer
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- //convert buffer to zero end array
- sbuf[len]='\0';
- //use string because easier to handle
- response =(const char*)sbuf;
- LOG(response);
- //if there is a wait it means purge is done
- if (response.indexOf("wait")>-1) {
- LOG("Exit start writing\r\n");
- break;
- }
- if (response.indexOf("Resend")>-1 || response.indexOf("failed")>-1) {
- com_error = true;
- web_interface->blockserial = false;
- LOG("Error start writing\r\n");
- break;
- }
- }
- delay(5);
- }
- //Upload write
- //**************
- //upload is on going with data coming by 2K blocks
- } else if((upload.status == UPLOAD_FILE_WRITE) && (com_error == false)) { //if com error no need to send more data to serial
- web_interface->_upload_status= UPLOAD_STATUS_ONGOING;
-#ifdef DEBUG_PERFORMANCE
- filesize+=upload.currentSize;
- uint32_t startwrite = millis();
-#endif
- for (int pos = 0; pos < upload.currentSize; pos++) { //parse full post data
- if (buffer_size < MAX_RESEND_BUFFER-1) { //raise error/handle if overbuffer - copy is space available
- //remove/ignore every comment to save transfert time and avoid over buffer issues
- if (upload.buf[pos] == ';') {
- is_comment = true;
- previous = ';';
- }
- if (!is_comment) {
- buffer_line[buffer_size] = upload.buf[pos]; //copy current char to buffer to send/resend
- buffer_size++;
- //convert buffer to zero end array
- buffer_line[buffer_size] = '\0';
- //check it is not an end line char and line is not empty
- if (((buffer_line[0] == '\n') && (buffer_size==1)) ||((buffer_line[1] == '\n') && (buffer_line[0] == '\r') && (buffer_size==2)) || ((buffer_line[0] == ' ') && (buffer_size==1)) ) {
- //ignore empty line
- buffer_size=0;
- buffer_line[buffer_size] = '\0';
- }
- //line is not empty so check if last char is an end line
- //if error no need to proceed
- else if (((buffer_line[buffer_size-1] == '\n')) && (com_error == false)) { //end of line and no error
- //if resend use buffer
- bool success = false;
-
- //check NB_RETRY times if get no error when send line
- for (int r = 0 ; r < NB_RETRY ; r++) {
- response = "";
- //print out line
- ESP_SERIAL_OUT.print(buffer_line);
- LOG(buffer_line);
- //ensure buffer is empty before continuing
- ESP_SERIAL_OUT.flush();
- //wait for answer with time out
- for (int retry=0; retry < 30; retry++) { //time out 30x5ms = 150ms
- //if there is serial data
- if(ESP_SERIAL_OUT.available()) {
- //get size of available data
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- //read serial buffer
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- //convert buffer in zero end array
- sbuf[len]='\0';
- //use string because easier
- response = (const char*)sbuf;
- LOG("Retry:");
- LOG(String(retry));
- LOG("\r\n");
- LOG(response);
- //if buffer contain ok or wait - it means command is pass
- if ((response.indexOf("wait")>-1)||(response.indexOf("ok")>-1)) {
- success = true;
- break;
- }
- //if buffer contain resend then need to resend
- if (response.indexOf("Resend") > -1) { //if error
- success = false;
- break;
- }
- }
- delay(5);
- }
- //if command is pass no need to retry
- if (success == true) {
- break;
- }
- //purge extra serial if any
- if(ESP_SERIAL_OUT.available()) {
- //get size of available data
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- //read serial buffer
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- //convert buffer in zero end array
- sbuf[len]='\0';
- }
- }
- //if even after the number of retry still have error - then we are in error
- if (!success) {
- //raise error
- LOG("Error detected\r\n");
- LOG(response);
- com_error = true;
- }
- //reset buffer for next command
- buffer_size = 0;
- buffer_line[buffer_size] = '\0';
- }
- } else { //it is a comment
- if (upload.buf[pos] == '\r') { //store if CR
- previous = '\r';
- } else if (upload.buf[pos] == '\n') { //this is the end of the comment
- is_comment = false;
- if (buffer_size > 0) {
- if (previous == '\r') {
- pos--;
- }
- pos--; //do a loop back and process as normal
- }
- previous = '\n';
- }//if not just ignore and continue
- else {
- previous = upload.buf[pos];
- }
-
- }
- } else { //raise error
- LOG("\r\nlong line detected\r\n");
- LOG(buffer_line);
- com_error = true;
- }
- }
-#ifdef DEBUG_PERFORMANCE
- write_time += (millis()-startwrite);
-#endif
- //Upload end
- //**************
- } else if(upload.status == UPLOAD_FILE_END) {
- if (buffer_size > 0) { //if last part does not have '\n'
- //print the line
- ESP_SERIAL_OUT.print(buffer_line);
- if (is_comment && (previous == '\r')) {
- ESP_SERIAL_OUT.print("\r\n");
- } else {
- ESP_SERIAL_OUT.print("\n");
- }
- ESP_SERIAL_OUT.flush();
- //if resend use buffer
- bool success = false;
- //check NB_RETRY times if get no error when send line
- for (int r = 0 ; r < NB_RETRY ; r++) {
- response = "";
- ESP_SERIAL_OUT.print(buffer_line);
- ESP_SERIAL_OUT.flush();
- //wait for answer with time out
- for (int retry=0; retry < 20; retry++) { //time out
- if(ESP_SERIAL_OUT.available()) {
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- sbuf[len]='\0';
- response = (const char*)sbuf;
- if ((response.indexOf("wait")>-1)||(response.indexOf("ok")>-1)) {
- success = true;
- break;
- }
- if (response.indexOf("Resend") > -1) { //if error
- success = false;
- break;
- }
- }
- delay(5);
- }
- if (success == true) {
- break;
- }
- }
- if (!success) {
- //raise error
- LOG("Error detected 2\r\n");
- LOG(response);
- com_error = true;
- }
- //reset buffer for next command
- buffer_size = 0;
- buffer_line[buffer_size] = '\0';
-
- }
- LOG("Upload finished ");
- buffer_size=0;
- buffer_line[buffer_size] = '\0';
- //send M29 command to close file on SD
- ESP_SERIAL_OUT.print("\r\nM29\r\n");
- ESP_SERIAL_OUT.flush();
- web_interface->blockserial = false;
- delay(1000);//give time to FW
- //resend M29 command to close file on SD as first command may be lost
- ESP_SERIAL_OUT.print("\r\nM29\r\n");
- ESP_SERIAL_OUT.flush();
-#ifdef DEBUG_PERFORMANCE
- uint32_t endupload = millis();
- DEBUG_PERF_VARIABLE.add(String(endupload-startupload).c_str());
- DEBUG_PERF_VARIABLE.add(String(write_time).c_str());
- DEBUG_PERF_VARIABLE.add(String(filesize).c_str());
-#endif
- if (com_error) {
- web_interface->blockserial = false;
- LOG("with error\r\n");
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- if (!client_closed){
- //web_interface->web_server.client().stopAll();
- LOG("Need to stop");
- client_closed = true;
- }
- filename = "M30 " + filename;
- ESP_SERIAL_OUT.println(filename);
- ESP_SERIAL_OUT.println("M117 SD upload failed");
- ESP_SERIAL_OUT.flush();
-
- } else {
- LOG("with success\r\n");
- web_interface->_upload_status=UPLOAD_STATUS_SUCCESSFUL;
- ESP_SERIAL_OUT.println("M117 SD upload done");
- ESP_SERIAL_OUT.flush();
- }
- //Upload cancelled
- //**************
- } else { //UPLOAD_FILE_ABORTED
- LOG("Error, Something happened\r\n");
- com_error = true;
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- buffer_size=0;
- buffer_line[buffer_size] = '\0';
- //send M29 command to close file on SD
- ESP_SERIAL_OUT.print("\r\nM29\r\n");
- ESP_SERIAL_OUT.flush();
- web_interface->blockserial = false;
- delay(1000);
- //resend M29 command to close file on SD as first command may be lost
- ESP_SERIAL_OUT.print("\r\nM29\r\n");
- ESP_SERIAL_OUT.flush();
- filename = "M30 " + filename;
- ESP_SERIAL_OUT.println(filename);
- ESP_SERIAL_OUT.println("M117 SD upload failed");
- ESP_SERIAL_OUT.flush();
- }
-}
-
-
-//FW update using Web interface
-#ifdef WEB_UPDATE_FEATURE
-void WebUpdateUpload()
-{
- static size_t last_upload_update;
- static uint32_t maxSketchSpace ;
- //only admin can update FW
- if(web_interface->is_authenticated() != LEVEL_ADMIN) {
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
-#ifdef ARDUINO_ARCH_ESP8266
- web_interface->web_server.client().stopAll();
-#else
- web_interface->web_server.client().stop();
-#endif
- ESP_SERIAL_OUT.println("M117 Update failed");
- LOG("SD Update failed\r\n");
- return;
- }
- //get current file ID
- HTTPUpload& upload = (web_interface->web_server).upload();
- //Upload start
- //**************
- if(upload.status == UPLOAD_FILE_START) {
- ESP_SERIAL_OUT.println(F("M117 Update Firmware"));
- web_interface->_upload_status= UPLOAD_STATUS_ONGOING;
-#ifdef ARDUINO_ARCH_ESP8266
- WiFiUDP::stopAll();
-#endif
-#ifdef ARDUINO_ARCH_ESP8266
- maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
-#else
-//Not sure can do OTA on 2Mb board
- maxSketchSpace = (ESP.getFlashChipSize()>0x20000)?0x140000:0x140000/2;
-#endif
- last_upload_update = 0;
- if(!Update.begin(maxSketchSpace)) { //start with max available size
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- } else {
- if (( CONFIG::GetFirmwareTarget() == REPETIER4DV) || (CONFIG::GetFirmwareTarget() == REPETIER)) ESP_SERIAL_OUT.println(F("M117 Update 0%%"));
- else ESP_SERIAL_OUT.println(F("M117 Update 0%"));
- }
- //Upload write
- //**************
- } else if(upload.status == UPLOAD_FILE_WRITE) {
- //check if no error
- if (web_interface->_upload_status == UPLOAD_STATUS_ONGOING) {
- //we do not know the total file size yet but we know the available space so let's use it
- if ( ((100 * upload.totalSize) / maxSketchSpace) !=last_upload_update) {
- last_upload_update = (100 * upload.totalSize) / maxSketchSpace;
- ESP_SERIAL_OUT.print(F("M117 Update "));
- ESP_SERIAL_OUT.print(last_upload_update);
- if (( CONFIG::GetFirmwareTarget() == REPETIER4DV) || (CONFIG::GetFirmwareTarget() == REPETIER)) ESP_SERIAL_OUT.println(F("%%"));
- else ESP_SERIAL_OUT.println(F("%"));
- }
- if(Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- }
- }
- //Upload end
- //**************
- } else if(upload.status == UPLOAD_FILE_END) {
- if(Update.end(true)) { //true to set the size to the current progress
- //Now Reboot
- if (( CONFIG::GetFirmwareTarget() == REPETIER4DV) || (CONFIG::GetFirmwareTarget() == REPETIER)) ESP_SERIAL_OUT.println(F("M117 Update 100%%"));
- else ESP_SERIAL_OUT.println(F("M117 Update 100%"));
- web_interface->_upload_status=UPLOAD_STATUS_SUCCESSFUL;
- }
- } else if(upload.status == UPLOAD_FILE_ABORTED) {
- ESP_SERIAL_OUT.println(F("M117 Update Failed"));
- Update.end();
- web_interface->_upload_status=UPLOAD_STATUS_CANCELLED;
- }
- delay(0);
-}
-
-void handleUpdate()
-{
- level_authenticate_type auth_level = web_interface->is_authenticated();
- if (auth_level != LEVEL_ADMIN) {
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
- web_interface->web_server.send(403,"text/plain","Not allowed, log in first!\n");
- return;
- }
- String jsonfile = "{\"status\":\"" ;
- jsonfile+=CONFIG::intTostr(web_interface->_upload_status);
- jsonfile+="\"}";
- //send status
- web_interface->web_server.sendHeader("Cache-Control", "no-cache");
- web_interface->web_server.send(200, "application/json", jsonfile);
- //if success restart
- if (web_interface->_upload_status==UPLOAD_STATUS_SUCCESSFUL) {
- web_interface->restartmodule=true;
- } else {
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
- }
-}
-#endif
-
-//SPIFFS files list and file commands
-void handleFileList()
-{
- level_authenticate_type auth_level = web_interface->is_authenticated();
- if (auth_level == LEVEL_GUEST) {
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
- web_interface->web_server.send(401,"text/plain","Authentication failed!\n");
- return;
- }
- String path ;
- String status = "Ok";
- if ((web_interface->_upload_status == UPLOAD_STATUS_FAILED) || (web_interface->_upload_status == UPLOAD_STATUS_CANCELLED)) {
- status = "Upload failed";
- }
- //be sure root is correct according authentication
- if (auth_level == LEVEL_ADMIN) {
- path = "/";
- } else {
- path = "/user";
- }
- //get current path
- if(web_interface->web_server.hasArg("path")) {
- path += web_interface->web_server.arg("path") ;
- }
- //to have a clean path
- path.trim();
- path.replace("//","/");
- if (path[path.length()-1] !='/') {
- path +="/";
- }
- //check if query need some action
- if(web_interface->web_server.hasArg("action")) {
- //delete a file
- if(web_interface->web_server.arg("action") == "delete" && web_interface->web_server.hasArg("filename")) {
- String filename;
- String shortname = web_interface->web_server.arg("filename");
- shortname.replace("/","");
- filename = path + web_interface->web_server.arg("filename");
- filename.replace("//","/");
- if(!SPIFFS.exists(filename)) {
- status = shortname + F(" does not exists!");
- } else {
- if (SPIFFS.remove(filename)) {
- status = shortname + F(" deleted");
- //what happen if no "/." and no other subfiles ?
-#ifdef ARDUINO_ARCH_ESP8266
- FS_DIR dir = SPIFFS.openDir(path);
- if (!dir.next()) {
-#else
- String ptmp = path;
- if ((path != "/") && (path[path.length()-1]='/'))ptmp = path.substring(0,path.length()-1);
- FS_FILE dir = SPIFFS.open(ptmp);
- FS_FILE dircontent = dir.openNextFile();
- if (!dircontent) {
-#endif
- //keep directory alive even empty
- FS_FILE r = SPIFFS.open(path+"/.", SPIFFS_FILE_WRITE);
- if (r) {
- r.close();
- }
- }
- } else {
- status = F("Cannot deleted ") ;
- status+=shortname ;
- }
- }
- }
- //delete a directory
- if(web_interface->web_server.arg("action") == "deletedir" && web_interface->web_server.hasArg("filename")) {
- String filename;
- String shortname = web_interface->web_server.arg("filename");
- shortname.replace("/","");
- filename = path + web_interface->web_server.arg("filename");
- filename += "/";
- filename.replace("//","/");
- if (filename != "/") {
- bool delete_error = false;
-#ifdef ARDUINO_ARCH_ESP8266
- FS_DIR dir = SPIFFS.openDir(path + shortname);
- {
- while (dir.next()) {
-#else
- FS_FILE dir = SPIFFS.open(path + shortname);
- {
- FS_FILE file2deleted = dir.openNextFile();
- while (file2deleted) {
-#endif
-#ifdef ARDUINO_ARCH_ESP8266
- String fullpath = dir.fileName();
-#else
- String fullpath = file2deleted.name();
-#endif
- if (!SPIFFS.remove(fullpath)) {
- delete_error = true;
- status = F("Cannot deleted ") ;
- status+=fullpath;
- }
-#ifdef ARDUINO_ARCH_ESP32
- file2deleted = dir.openNextFile();
-#endif
- }
- }
- if (!delete_error) {
- status = shortname ;
- status+=" deleted";
- }
- }
- }
- //create a directory
- if(web_interface->web_server.arg("action")=="createdir" && web_interface->web_server.hasArg("filename")) {
- String filename;
- filename = path + web_interface->web_server.arg("filename") +"/.";
- String shortname = web_interface->web_server.arg("filename");
- shortname.replace("/","");
- filename.replace("//","/");
- if(SPIFFS.exists(filename)) {
- status = shortname + F(" already exists!");
- } else {
- FS_FILE r = SPIFFS.open(filename,SPIFFS_FILE_WRITE);
- if (!r) {
- status = F("Cannot create ");
- status += shortname ;
- } else {
- r.close();
- status = shortname + F(" created");
- }
- }
- }
- }
- String jsonfile = "{";
-#ifdef ARDUINO_ARCH_ESP8266
- FS_DIR dir = SPIFFS.openDir(path);
-#else
- String ptmp = path;
- if ((path != "/") && (path[path.length()-1]='/'))ptmp = path.substring(0,path.length()-1);
- FS_FILE dir = SPIFFS.open(ptmp);
-#endif
- jsonfile+="\"files\":[";
- bool firstentry=true;
- String subdirlist="";
-#ifdef ARDUINO_ARCH_ESP8266
- while (dir.next()) {
- String filename = dir.fileName();
-#else
- File fileparsed = dir.openNextFile();
- while (fileparsed) {
- String filename = fileparsed.name();
-#endif
- String size ="";
- bool addtolist=true;
- //remove path from name
- filename = filename.substring(path.length(),filename.length());
- //check if file or subfile
- if (filename.indexOf("/")>-1) {
- //Do not rely on "/." to define directory as SPIFFS upload won't create it but directly files
- //and no need to overload SPIFFS if not necessary to create "/." if no need
- //it will reduce SPIFFS available space so limit it to creation
- filename = filename.substring(0,filename.indexOf("/"));
- String tag="*";
- tag += filename + "*";
- if (subdirlist.indexOf(tag)>-1 || filename.length()==0) { //already in list
- addtolist = false; //no need to add
- } else {
- size = -1; //it is subfile so display only directory, size will be -1 to describe it is directory
- if (subdirlist.length()==0) {
- subdirlist+="*";
- }
- subdirlist += filename + "*"; //add to list
- }
- } else {
- //do not add "." file
- if (!((filename==".") || (filename==""))) {
-#ifdef ARDUINO_ARCH_ESP8266
- size = CONFIG::formatBytes(dir.fileSize());
-#else
- size = CONFIG::formatBytes(fileparsed.size());
-#endif
-
- } else {
- addtolist = false;
- }
- }
- if(addtolist) {
- if (!firstentry) {
- jsonfile+=",";
- } else {
- firstentry=false;
- }
- jsonfile+="{";
- jsonfile+="\"name\":\"";
- jsonfile+=filename;
- jsonfile+="\",\"size\":\"";
- jsonfile+=size;
- jsonfile+="\"";
- jsonfile+="}";
- }
-#ifdef ARDUINO_ARCH_ESP32
- fileparsed = dir.openNextFile();
-#endif
- }
- jsonfile+="],";
- jsonfile+="\"path\":\"" + path + "\",";
- jsonfile+="\"status\":\"" + status + "\",";
- size_t totalBytes;
- size_t usedBytes;
-#ifdef ARDUINO_ARCH_ESP8266
- fs::FSInfo info;
- SPIFFS.info(info);
- totalBytes = info.totalBytes;
- usedBytes = info.usedBytes;
-#else
- totalBytes = SPIFFS.totalBytes();
- usedBytes = SPIFFS.usedBytes();
-#endif
- jsonfile+="\"total\":\"" + CONFIG::formatBytes(totalBytes) + "\",";
- jsonfile+="\"used\":\"" + CONFIG::formatBytes(usedBytes) + "\",";
- jsonfile.concat(F("\"occupation\":\""));
- jsonfile+= CONFIG::intTostr(100*usedBytes/totalBytes);
- jsonfile+="\"";
- jsonfile+="}";
- path = "";
- web_interface->web_server.sendHeader("Cache-Control", "no-cache");
- web_interface->web_server.send(200, "application/json", jsonfile);
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
-}
-
-//serial SD files list
-void handle_serial_SDFileList()
-{
- //this is only for admin an user
- if (web_interface->is_authenticated() == LEVEL_GUEST) {
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
- web_interface->web_server.sendHeader("Cache-Control", "no-cache");
- web_interface->web_server.send(401, "application/json", "{\"status\":\"Authentication failed!\"}");
- return;
- }
- LOG("serial SD upload done\r\n")
- String sstatus="Ok";
- if ((web_interface->_upload_status == UPLOAD_STATUS_FAILED) || (web_interface->_upload_status == UPLOAD_STATUS_CANCELLED)) {
- sstatus = "Upload failed";
- web_interface->_upload_status = UPLOAD_STATUS_NONE;
- }
- String jsonfile = "{\"status\":\"" + sstatus + "\"}";
- web_interface->web_server.sendHeader("Cache-Control", "no-cache");
- web_interface->web_server.send(200, "application/json", jsonfile);
- web_interface->blockserial = false;
- web_interface->_upload_status=UPLOAD_STATUS_NONE;
-}
-
-
-//do a redirect to avoid to many query
-//and handle not registred path
-void handle_not_found()
-{
- static const char NOT_AUTH_NF [] PROGMEM = "HTTP/1.1 301 OK\r\nLocation: /\r\nCache-Control: no-cache\r\n\r\n";
-
- if (web_interface->is_authenticated() == LEVEL_GUEST) {
- web_interface->web_server.sendContent_P(NOT_AUTH_NF);
- //web_interface->web_server.client().stop();
- return;
- }
- bool page_not_found = false;
- String path = web_interface->web_server.urlDecode(web_interface->web_server.uri());
- String contentType = web_interface->getContentType(path);
- String pathWithGz = path + ".gz";
- LOG("request:")
- LOG(path)
- LOG("\r\n")
-#ifdef DEBUG_ESP3D
- int nb = web_interface->web_server.args();
- for (int i = 0 ; i < nb; i++) {
- LOG(web_interface->web_server.argName(i))
- LOG(":")
- LOG(web_interface->web_server.arg(i))
- LOG("\r\n")
-
- }
-#endif
- LOG("type:")
- LOG(contentType)
- LOG("\r\n")
- if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) {
- if(SPIFFS.exists(pathWithGz)) {
- path = pathWithGz;
- }
- FS_FILE file = SPIFFS.open(path, SPIFFS_FILE_READ);
- web_interface->web_server.streamFile(file, contentType);
- file.close();
- return;
- } else {
- page_not_found = true;
- }
-
- if (page_not_found ) {
-#ifdef CAPTIVE_PORTAL_FEATURE
- if (WiFi.getMode()!=WIFI_STA ) {
- String contentType=FPSTR(PAGE_CAPTIVE);
- String stmp = WiFi.softAPIP().toString();
- //Web address = ip + port
- String KEY_IP = F("$WEB_ADDRESS$");
- String KEY_QUERY = F("$QUERY$");
- if (wifi_config.iweb_port!=80) {
- stmp+=":";
- stmp+=CONFIG::intTostr(wifi_config.iweb_port);
- }
- contentType.replace(KEY_IP,stmp);
- contentType.replace(KEY_IP,stmp);
- contentType.replace(KEY_QUERY,web_interface->web_server.uri());
- web_interface->web_server.send(200,"text/html",contentType);
- //web_interface->web_server.sendContent_P(NOT_AUTH_NF);
- //web_interface->web_server.client().stop();
- return;
- }
-#endif
- LOG("Page not found\r\n")
- path = F("/404.htm");
- contentType = web_interface->getContentType(path);
- pathWithGz = path + F(".gz");
- if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) {
- if(SPIFFS.exists(pathWithGz)) {
- path = pathWithGz;
- }
- FS_FILE file = SPIFFS.open(path, SPIFFS_FILE_READ);
- web_interface->web_server.streamFile(file, contentType);
- file.close();
-
- } else {
- //if not template use default page
- contentType=FPSTR(PAGE_404);
- String stmp;
- if (WiFi.getMode()==WIFI_STA ) {
- stmp=WiFi.localIP().toString();
- } else {
- stmp=WiFi.softAPIP().toString();
- }
- //Web address = ip + port
- String KEY_IP = F("$WEB_ADDRESS$");
- String KEY_QUERY = F("$QUERY$");
- if (wifi_config.iweb_port!=80) {
- stmp+=":";
- stmp+=CONFIG::intTostr(wifi_config.iweb_port);
- }
- contentType.replace(KEY_IP,stmp);
- contentType.replace(KEY_QUERY,web_interface->web_server.uri());
- web_interface->web_server.send(200,"text/html",contentType);
- }
- }
-}
-
-#ifdef AUTHENTICATION_FEATURE
-void handle_login()
-{
- String smsg;
- String sUser,sPassword;
- String auths;
- int code = 200;
- bool msg_alert_error=false;
- //disconnect can be done anytime no need to check credential
- if (web_interface->web_server.hasArg("DISCONNECT")) {
- String cookie = web_interface->web_server.header("Cookie");
- int pos = cookie.indexOf("ESPSESSIONID=");
- String sessionID;
- if (pos!= -1) {
- int pos2 = cookie.indexOf(";",pos);
- sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2);
- }
- web_interface->ClearAuthIP(web_interface->web_server.client().remoteIP(), sessionID.c_str());
- web_interface->web_server.sendHeader("Set-Cookie","ESPSESSIONID=0");
- web_interface->web_server.sendHeader("Cache-Control","no-cache");
- String buffer2send = "{\"status\":\"Ok\",\"authentication_lvl\":\"guest\"}";
- web_interface->web_server.send(code, "application/json", buffer2send);
- //web_interface->web_server.client().stop();
- return;
- }
-
- level_authenticate_type auth_level= web_interface->is_authenticated();
- if (auth_level == LEVEL_GUEST) auths = F("guest");
- else if (auth_level == LEVEL_USER) auths = F("user");
- else if (auth_level == LEVEL_ADMIN) auths = F("admin");
- else auths = F("???");
-
- //check is it is a submission or a query
- if (web_interface->web_server.hasArg("SUBMIT")) {
- //is there a correct list of query?
- if ( web_interface->web_server.hasArg("PASSWORD")&& web_interface->web_server.hasArg("USER")) {
- //USER
- sUser = web_interface->web_server.arg("USER");
- if ( !((sUser==FPSTR(DEFAULT_ADMIN_LOGIN)) || (sUser==FPSTR(DEFAULT_USER_LOGIN)))) {
- msg_alert_error=true;
- smsg=F("Error : Incorrect User");
- code=401;
- }
- if (msg_alert_error == false) {
- //Password
- sPassword = web_interface->web_server.arg("PASSWORD");
- String sadminPassword;
-
- if (!CONFIG::read_string(EP_ADMIN_PWD, sadminPassword, MAX_LOCAL_PASSWORD_LENGTH)) {
- sadminPassword=FPSTR(DEFAULT_ADMIN_PWD);
- }
-
- String suserPassword;
-
- if (!CONFIG::read_string(EP_USER_PWD, suserPassword, MAX_LOCAL_PASSWORD_LENGTH)) {
- suserPassword=FPSTR(DEFAULT_USER_PWD);
- }
-
- if(!(((sUser==FPSTR(DEFAULT_ADMIN_LOGIN)) && (strcmp(sPassword.c_str(),sadminPassword.c_str())==0)) ||
- ((sUser==FPSTR(DEFAULT_USER_LOGIN)) && (strcmp(sPassword.c_str(),suserPassword.c_str()) == 0)))) {
- msg_alert_error=true;
- smsg=F("Error: Incorrect password");
- code = 401;
- }
- }
- } else {
- msg_alert_error=true;
- smsg = F("Error: Missing data");
- code = 500;
- }
- //change password
- if ( web_interface->web_server.hasArg("PASSWORD")&& web_interface->web_server.hasArg("USER") && web_interface->web_server.hasArg("NEWPASSWORD") && (msg_alert_error==false) ) {
- String newpassword = web_interface->web_server.arg("NEWPASSWORD");
- if (CONFIG::isLocalPasswordValid(newpassword.c_str())) {
- int pos=0;
- if(sUser==FPSTR(DEFAULT_ADMIN_LOGIN)) pos = EP_ADMIN_PWD;
- else pos = EP_USER_PWD;
- if (!CONFIG::write_string(pos,newpassword.c_str())){
- msg_alert_error=true;
- smsg = F("Error: Cannot apply changes");
- code = 500;
- }
- } else {
- msg_alert_error=true;
- smsg = F("Error: Incorrect password");
- code = 500;
- }
- }
- if ((code == 200) || (code == 500)) {
- level_authenticate_type current_auth_level;
- if(sUser == FPSTR(DEFAULT_ADMIN_LOGIN)) {
- current_auth_level = LEVEL_ADMIN;
- } else if(sUser == FPSTR(DEFAULT_USER_LOGIN)){
- current_auth_level = LEVEL_USER;
- } else {
- current_auth_level = LEVEL_GUEST;
- }
- //create Session
- if ((current_auth_level != auth_level) || (auth_level== LEVEL_GUEST)) {
- auth_ip * current_auth = new auth_ip;
- current_auth->level = current_auth_level;
- current_auth->ip=web_interface->web_server.client().remoteIP();
- strcpy(current_auth->sessionID,web_interface->create_session_ID());
- strcpy(current_auth->userID,sUser.c_str());
- current_auth->last_time=millis();
- if (web_interface->AddAuthIP(current_auth)) {
- String tmps ="ESPSESSIONID=";
- tmps+=current_auth->sessionID;
- web_interface->web_server.sendHeader("Set-Cookie",tmps);
- web_interface->web_server.sendHeader("Cache-Control","no-cache");
- switch(current_auth->level) {
- case LEVEL_ADMIN:
- auths = "admin";
- break;
- case LEVEL_USER:
- auths = "user";
- break;
- default:
- auths = "guest";
- }
- } else {
- delete current_auth;
- msg_alert_error=true;
- code = 500;
- smsg = F("Error: Too many connections");
- }
- }
- }
- if (code == 200) smsg = F("Ok");
-
- //build JSON
- String buffer2send = "{\"status\":\"" + smsg + "\",\"authentication_lvl\":\"";
- buffer2send += auths;
- buffer2send += "\"}";
- web_interface->web_server.send(code, "application/json", buffer2send);
- } else {
- if (auth_level != LEVEL_GUEST) {
- String cookie = web_interface->web_server.header("Cookie");
- int pos = cookie.indexOf("ESPSESSIONID=");
- String sessionID;
- if (pos!= -1) {
- int pos2 = cookie.indexOf(";",pos);
- sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2);
- auth_ip * current_auth_info = web_interface->GetAuth(web_interface->web_server.client().remoteIP(), sessionID.c_str());
- if (current_auth_info != NULL){
- sUser = current_auth_info->userID;
- }
- }
- }
- String buffer2send = "{\"status\":\"200\",\"authentication_lvl\":\"";
- buffer2send += auths;
- buffer2send += "\",\"user\":\"";
- buffer2send += sUser;
- buffer2send +="\"}";
- web_interface->web_server.send(code, "application/json", buffer2send);
- }
-}
-#endif
-
-
-//Handle web command query and send answer
-void handle_web_command()
-{
- level_authenticate_type auth_level= web_interface->is_authenticated();
- /* if (auth_level == LEVEL_GUEST) {
- web_interface->web_server.send(403,"text/plain","Not allowed, log in first!\n");
- return;
- }*/
- String buffer2send = "";
- LOG(String (web_interface->web_server.args()))
- LOG(" Web command\r\n")
-#ifdef DEBUG_ESP3D
- int nb = web_interface->web_server.args();
- for (int i = 0 ; i < nb; i++) {
- LOG(web_interface->web_server.argName(i))
- LOG(":")
- LOG(web_interface->web_server.arg(i))
- LOG("\r\n")
- }
-#endif
- String cmd = "";
- int count ;
- if (web_interface->web_server.hasArg("plain") || web_interface->web_server.hasArg("commandText")) {
- if (web_interface->web_server.hasArg("plain")) {
- cmd = web_interface->web_server.arg("plain");
- } else {
- cmd = web_interface->web_server.arg("commandText");
- }
- LOG("Web Command:")
- LOG(cmd)
- LOG("\r\n")
- } else {
- LOG("invalid argument\r\n")
- web_interface->web_server.send(200,"text/plain","Invalid command");
- return;
- }
- //if it is for ESP module [ESPXXX]
- cmd.trim();
- int ESPpos = cmd.indexOf("[ESP");
- if (ESPpos>-1) {
- //is there the second part?
- int ESPpos2 = cmd.indexOf("]",ESPpos);
- if (ESPpos2>-1) {
- //Split in command and parameters
- String cmd_part1=cmd.substring(ESPpos+4,ESPpos2);
- String cmd_part2="";
- //only [ESP800] is allowed login free if authentication is enabled
- if ((auth_level == LEVEL_GUEST) && (cmd_part1.toInt()!=800)) {
- web_interface->web_server.send(401,"text/plain","Authentication failed!\n");
- return;
- }
- //is there space for parameters?
- if (ESPpos2web_server.send(401,"text/plain","Authentication failed!\n");
- return;
- }
- //send command to serial as no need to transfer ESP command
- //to avoid any pollution if Uploading file to SDCard
- if ((web_interface->blockserial) == false) {
- //block every query
- web_interface->blockserial = true;
- LOG("Block Serial\r\n")
- //empty the serial buffer and incoming data
- LOG("Start PurgeSerial\r\n")
- if(ESP_SERIAL_OUT.available()) {
- BRIDGE::processFromSerial2TCP();
- delay(1);
- }
- LOG("End PurgeSerial\r\n")
- web_interface->web_server.setContentLength(CONTENT_LENGTH_UNKNOWN);
- web_interface->web_server.sendHeader("Content-Type","text/plain",true);
- web_interface->web_server.sendHeader("Cache-Control","no-cache");
- web_interface->web_server.send(200);
- //send command
- LOG(String(cmd.length()))
- LOG("Start PurgeSerial\r\n")
- if(ESP_SERIAL_OUT.available()) {
- BRIDGE::processFromSerial2TCP();
- delay(1);
- }
- LOG("End PurgeSerial\r\n")
- LOG("Send Command\r\n")
- ESP_SERIAL_OUT.println(cmd);
- count = 0;
- String current_buffer;
- String current_line;
- //int pos;
- int temp_counter = 0;
- String tmp;
- bool datasent = false;
- //pickup the list
- while (count < MAX_TRY) {
- //give some time between each buffer
- if (ESP_SERIAL_OUT.available()) {
- count = 0;
- size_t len = ESP_SERIAL_OUT.available();
- uint8_t sbuf[len+1];
- //read buffer
- ESP_SERIAL_OUT.readBytes(sbuf, len);
- //change buffer as string
- sbuf[len]='\0';
- //add buffer to current one if any
- current_buffer += (char * ) sbuf;
- while (current_buffer.indexOf("\n") !=-1) {
- //remove the possible "\r"
- current_buffer.replace("\r","");
- //pos = current_buffer.indexOf("\n");
- //get line
- current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
- //if line is command ack - just exit so save the time out period
- if ((current_line == "ok") || (current_line == "wait")) {
- count = MAX_TRY;
- LOG("Found ok\r\n")
- break;
- }
- //get the line and transmit it
- LOG("Check command: ")
- LOG(current_line)
- LOG("\r\n")
- //check command
- if ((CONFIG::GetFirmwareTarget() == REPETIER) || (CONFIG::GetFirmwareTarget() == REPETIER4DV)){
- //save time no need to continue
- if (current_line.indexOf("busy:") > -1) {
- temp_counter++;
- } else if (COMMAND::check_command(current_line, NO_PIPE, false)) {
- temp_counter ++ ;
- }
- }else {
- if (COMMAND::check_command(current_line, NO_PIPE, false)) {
- temp_counter ++ ;
- }
- }
- if (temp_counter > 5) {
- break;
- }
- if ((CONFIG::GetFirmwareTarget() == REPETIER) || (CONFIG::GetFirmwareTarget() == REPETIER4DV)) {
- if (!current_line.startsWith( "ok "))
- {
- buffer2send +=current_line;
- buffer2send +="\n";
- }
- } else {
- buffer2send +=current_line;
- buffer2send +="\n";
- }
- if (buffer2send.length() > 1200) {
- web_interface->web_server.sendContent(buffer2send);
- buffer2send = "";
- datasent = true;
- }
- //current remove line from buffer
- tmp = current_buffer.substring(current_buffer.indexOf("\n")+1,current_buffer.length());
- current_buffer = tmp;
- delay(0);
- }
- delay (0);
- } else {
- delay(1);
- }
- //it is sending too many temp status should be heating so let's exit the loop
- if (temp_counter > 5) {
- count = MAX_TRY;
- }
- count++;
- }
- //to be sure connection close
- if (buffer2send.length() > 0) {
- web_interface->web_server.sendContent(buffer2send);
- datasent = true;
- }
- if (!datasent) {
- web_interface->web_server.sendContent(" \r\n");
- }
- web_interface->web_server.sendContent("");
- LOG("Start PurgeSerial\r\n")
- if(ESP_SERIAL_OUT.available()) {
- BRIDGE::processFromSerial2TCP();
- delay(1);
- }
- LOG("End PurgeSerial\r\n")
- web_interface->blockserial = false;
- LOG("Release Serial\r\n")
- } else {
- web_interface->web_server.send(200,"text/plain","Serial is busy, retry later!");
- }
- }
-}
-
-//Handle web command query and sent ack or fail instead of answer
-void handle_web_command_silent()
-{
- level_authenticate_type auth_level= web_interface->is_authenticated();
- if (auth_level == LEVEL_GUEST) {
- web_interface->web_server.send(401,"text/plain","Authentication failed!\n");
- return;
- }
- String buffer2send = "";
- LOG(String (web_interface->web_server.args()))
- LOG(" Web silent command\r\n")
-#ifdef DEBUG_ESP3D
- int nb = web_interface->web_server.args();
- for (int i = 0 ; i < nb; i++) {
- LOG(web_interface->web_server.argName(i))
- LOG(":")
- LOG(web_interface->web_server.arg(i))
- LOG("\r\n")
- }
-#endif
- String cmd = "";
- //int count ;
- if (web_interface->web_server.hasArg("plain") || web_interface->web_server.hasArg("commandText")) {
- if (web_interface->web_server.hasArg("plain")) {
- cmd = web_interface->web_server.arg("plain");
- } else {
- cmd = web_interface->web_server.arg("commandText");
- }
- LOG("Web Command:")
- LOG(cmd)
- LOG("\r\n")
- } else {
- LOG("invalid argument\r\n")
- web_interface->web_server.send(200,"text/plain","Invalid command");
- return;
- }
- //if it is for ESP module [ESPXXX]
- cmd.trim();
- int ESPpos = cmd.indexOf("[ESP");
- if (ESPpos>-1) {
- //is there the second part?
- int ESPpos2 = cmd.indexOf("]",ESPpos);
- if (ESPpos2>-1) {
- //Split in command and parameters
- String cmd_part1=cmd.substring(ESPpos+4,ESPpos2);
- String cmd_part2="";
- //is there space for parameters?
- if (ESPpos2web_server.send(200,"text/plain","ok");
- } else {
- web_interface->web_server.send(500,"text/plain","error");
- }
-
- }
- //if not is not a valid [ESPXXX] command
- }
- } else {
- //send command to serial as no need to transfer ESP command
- //to avoid any pollution if Uploading file to SDCard
- if ((web_interface->blockserial) == false) {
- LOG("Send Command\r\n")
- //send command
- ESP_SERIAL_OUT.println(cmd);
- web_interface->web_server.send(200,"text/plain","ok");
- } else {
- web_interface->web_server.send(200,"text/plain","Serial is busy, retry later!");
- }
- }
-
-}
-
-#ifdef SSDP_FEATURE
-void handle_SSDP()
-{
- SSDP.schema(web_interface->web_server.client());
-}
-#endif
-
-//constructor
-WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):web_server(port)
-{
- //init what will handle "/"
- web_server.on("/",HTTP_ANY, handle_web_interface_root);
- web_server.on("/command",HTTP_ANY, handle_web_command);
- web_server.on("/command_silent",HTTP_ANY, handle_web_command_silent);
- web_server.on("/upload_serial", HTTP_ANY, handle_serial_SDFileList,SDFile_serial_upload);
- web_server.on("/files", HTTP_ANY, handleFileList,SPIFFSFileupload);
-#ifdef WEB_UPDATE_FEATURE
- web_server.on("/updatefw",HTTP_ANY, handleUpdate,WebUpdateUpload);
-#endif
-#ifdef AUTHENTICATION_FEATURE
- web_server.on("/login", HTTP_ANY, handle_login);
-#endif
- //TODO: to be reviewed
- web_server.on("/STATUS",HTTP_ANY, handle_web_interface_status);
-#ifdef SSDP_FEATURE
- web_server.on("/description.xml", HTTP_GET, handle_SSDP);
-#endif
-#ifdef CAPTIVE_PORTAL_FEATURE
- web_server.on("/generate_204",HTTP_ANY, handle_web_interface_root);
- web_server.on("/gconnectivitycheck.gstatic.com",HTTP_ANY, handle_web_interface_root);
- //do not forget the / at the end
- web_server.on("/fwlink/",HTTP_ANY, handle_web_interface_root);
-#endif
- web_server.onNotFound( handle_not_found);
- blockserial = false;
- restartmodule=false;
- //rolling list of 4entries with a maximum of 50 char for each entry
-#ifdef ERROR_MSG_FEATURE
- error_msg.setsize(4);
- error_msg.setlength(50);
-#endif
-#ifdef INFO_MSG_FEATURE
- info_msg.setsize(4);
- info_msg.setlength(50);
-#endif
-#ifdef STATUS_MSG_FEATURE
- status_msg.setsize(4);
- status_msg.setlength(50);
-#endif
- fsUploadFile=(FS_FILE)0;
- _head=NULL;
- _nb_ip=0;
- _upload_status=UPLOAD_STATUS_NONE;
-}
-//Destructor
-WEBINTERFACE_CLASS::~WEBINTERFACE_CLASS()
-{
-#ifdef INFO_MSG_FEATURE
- info_msg.clear();
-#endif
-#ifdef ERROR_MSG_FEATURE
- error_msg.clear();
-#endif
-#ifdef STATUS_MSG_FEATURE
- status_msg.clear();
-#endif
- while (_head) {
- auth_ip * current = _head;
- _head=_head->_next;
- delete current;
- }
- _nb_ip=0;
-}
-//check authentification
-level_authenticate_type WEBINTERFACE_CLASS::is_authenticated()
-{
-#ifdef AUTHENTICATION_FEATURE
- if (web_server.hasHeader("Cookie")) {
- String cookie = web_server.header("Cookie");
- int pos = cookie.indexOf("ESPSESSIONID=");
- if (pos!= -1) {
- int pos2 = cookie.indexOf(";",pos);
- String sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2);
- IPAddress ip = web_server.client().remoteIP();
- //check if cookie can be reset and clean table in same time
- return ResetAuthIP(ip,sessionID.c_str());
- }
- }
- return LEVEL_GUEST;
-#else
- return LEVEL_ADMIN;
-#endif
-}
-
-#ifdef AUTHENTICATION_FEATURE
-//add the information in the linked list if possible
-bool WEBINTERFACE_CLASS::AddAuthIP(auth_ip * item)
-{
- if (_nb_ip>MAX_AUTH_IP) {
- return false;
- }
- item->_next=_head;
- _head=item;
- _nb_ip++;
- return true;
-}
-
-//Session ID based on IP and time using 16 char
-char * WEBINTERFACE_CLASS::create_session_ID()
-{
- static char sessionID[17];
-//reset SESSIONID
- for (int i=0; i<17; i++) {
- sessionID[i]='\0';
- }
-//get time
- uint32_t now = millis();
-//get remote IP
- IPAddress remoteIP=web_server.client().remoteIP();
-//generate SESSIONID
- if (0>sprintf(sessionID,"%02X%02X%02X%02X%02X%02X%02X%02X",remoteIP[0],remoteIP[1],remoteIP[2],remoteIP[3],(uint8_t) ((now >> 0) & 0xff),(uint8_t) ((now >> 8) & 0xff),(uint8_t) ((now >> 16) & 0xff),(uint8_t) ((now >> 24) & 0xff))) {
- strcpy(sessionID,"NONE");
- }
- return sessionID;
-}
-
-
-
-bool WEBINTERFACE_CLASS::ClearAuthIP(IPAddress ip, const char * sessionID){
- auth_ip * current = _head;
- auth_ip * previous = NULL;
- bool done = false;
- while (current) {
- if ((ip == current->ip) && (strcmp(sessionID,current->sessionID)==0)) {
- //remove
- done = true;
- if (current ==_head) {
- _head=current->_next;
- _nb_ip--;
- delete current;
- current=_head;
- } else {
- previous->_next=current->_next;
- _nb_ip--;
- delete current;
- current=previous->_next;
- }
- } else {
- previous = current;
- current=current->_next;
- }
- }
- return done;
-}
-
-//Get info
-auth_ip * WEBINTERFACE_CLASS::GetAuth(IPAddress ip,const char * sessionID)
-{
- auth_ip * current = _head;
- auth_ip * previous = NULL;
- //get time
- //uint32_t now = millis();
- while (current) {
- if (ip==current->ip) {
- if (strcmp(sessionID,current->sessionID)==0) {
- //found
- return current;
- }
- }
- previous = current;
- current=current->_next;
- }
- return NULL;
-}
-
-//Review all IP to reset timers
-level_authenticate_type WEBINTERFACE_CLASS::ResetAuthIP(IPAddress ip,const char * sessionID)
-{
- auth_ip * current = _head;
- auth_ip * previous = NULL;
- //get time
- //uint32_t now = millis();
- while (current) {
- if ((millis()-current->last_time)>180000) {
- //remove
- if (current==_head) {
- _head=current->_next;
- _nb_ip--;
- delete current;
- current=_head;
- } else {
- previous->_next=current->_next;
- _nb_ip--;
- delete current;
- current=previous->_next;
- }
- } else {
- if (ip==current->ip) {
- if (strcmp(sessionID,current->sessionID)==0) {
- //reset time
- current->last_time=millis();
- return (level_authenticate_type)current->level;
- }
- }
- previous = current;
- current=current->_next;
- }
- }
- return LEVEL_GUEST;
-}
-#endif
-
-//Check what is the content tye according extension file
-String WEBINTERFACE_CLASS::getContentType(String filename)
-{
- if(filename.endsWith(".htm")) {
- return "text/html";
- } else if(filename.endsWith(".html")) {
- return "text/html";
- } else if(filename.endsWith(".css")) {
- return "text/css";
- } else if(filename.endsWith(".js")) {
- return "application/javascript";
- } else if(filename.endsWith(".png")) {
- return "image/png";
- } else if(filename.endsWith(".gif")) {
- return "image/gif";
- } else if(filename.endsWith(".jpeg")) {
- return "image/jpeg";
- } else if(filename.endsWith(".jpg")) {
- return "image/jpeg";
- } else if(filename.endsWith(".ico")) {
- return "image/x-icon";
- } else if(filename.endsWith(".xml")) {
- return "text/xml";
- } else if(filename.endsWith(".pdf")) {
- return "application/x-pdf";
- } else if(filename.endsWith(".zip")) {
- return "application/x-zip";
- } else if(filename.endsWith(".gz")) {
- return "application/x-gzip";
- } else if(filename.endsWith(".tpl")) {
- return "text/plain";
- } else if(filename.endsWith(".inc")) {
- return "text/plain";
- } else if(filename.endsWith(".txt")) {
- return "text/plain";
- }
- return "application/octet-stream";
-}
-
-
-WEBINTERFACE_CLASS * web_interface;
diff --git a/esp3d/webinterface.h b/esp3d/webinterface.h
deleted file mode 100644
index de3874a9..00000000
--- a/esp3d/webinterface.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- webinterface.h - ESP3D configuration class
-
- Copyright (c) 2014 Luc Lebosse. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef WEBINTERFACE_h
-#define WEBINTERFACE_h
-#include
-#include
-#include
-#ifndef FS_NO_GLOBALS
-#define FS_NO_GLOBALS
-#endif
-#include
-#ifdef ARDUINO_ARCH_ESP8266
-#include
-#else
-#include
-#endif
-
-
-#include "storestrings.h"
-
-#define MAX_EXTRUDERS 4
-
-struct auth_ip {
- IPAddress ip;
- level_authenticate_type level;
- char userID[17];
- char sessionID[17];
- uint32_t last_time;
- auth_ip * _next;
-};
-
-class WEBINTERFACE_CLASS
-{
-public:
- WEBINTERFACE_CLASS (int port = 80);
- ~WEBINTERFACE_CLASS();
-#ifdef ARDUINO_ARCH_ESP8266
- ESP8266WebServer web_server;
-#else
- WebServer web_server;
-#endif
- FS_FILE fsUploadFile;
-#ifdef ERROR_MSG_FEATURE
- STORESTRINGS_CLASS error_msg;
-#endif
-#ifdef INFO_MSG_FEATURE
- STORESTRINGS_CLASS info_msg;
-#endif
-#ifdef STATUS_MSG_FEATURE
- STORESTRINGS_CLASS status_msg;
-#endif
- bool restartmodule;
- String getContentType(String filename);
- level_authenticate_type is_authenticated();
- bool AddAuthIP(auth_ip * item);
- bool blockserial;
-#ifdef AUTHENTICATION_FEATURE
- level_authenticate_type ResetAuthIP(IPAddress ip,const char * sessionID);
- auth_ip * GetAuth(IPAddress ip,const char * sessionID);
- bool ClearAuthIP(IPAddress ip, const char * sessionID);
- char * create_session_ID();
-#endif
- uint8_t _upload_status;
-
-private:
- auth_ip * _head;
- uint8_t _nb_ip;
-};
-
-extern WEBINTERFACE_CLASS * web_interface;
-
-#endif
diff --git a/esp3d/wificonf.cpp b/esp3d/wificonf.cpp
deleted file mode 100644
index de45a921..00000000
--- a/esp3d/wificonf.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- wificonf.cpp - ESP3D configuration class
-
- Copyright (c) 2014 Luc Lebosse. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-#include "config.h"
-#include "wificonf.h"
-#include "bridge.h"
-#include "webinterface.h"
-
-#ifdef ARDUINO_ARCH_ESP8266
-#include "ESP8266WiFi.h"
-#ifdef MDNS_FEATURE
-#include
-#endif
-#else
-#include
-#include "esp_wifi.h"
-#ifdef MDNS_FEATURE
-#include
-#endif
-#endif
-#include "IPAddress.h"
-#ifdef CAPTIVE_PORTAL_FEATURE
-#include
-DNSServer dnsServer;
-const byte DNS_PORT = 53;
-#endif
-#ifdef ARDUINO_ARCH_ESP8266
-#include
-#else
-#include
-#endif
-#ifdef SSDP_FEATURE
-#include
-#endif
-#ifdef NETBIOS_FEATURE
-#ifdef ARDUINO_ARCH_ESP8266
-#include
-#else
-#include
-#endif
-#endif
-#ifdef ARDUINO_ARCH_ESP8266
-extern "C" {
-#include "user_interface.h"
-}
-#endif
-#ifdef TIMESTAMP_FEATURE
-#include
-#endif
-
-WIFI_CONFIG::WIFI_CONFIG()
-{
- iweb_port=DEFAULT_WEB_PORT;
- idata_port=DEFAULT_DATA_PORT;
- baud_rate=DEFAULT_BAUD_RATE;
- sleep_mode=DEFAULT_SLEEP_MODE;
- _hostname[0]=0;
-}
-
-int32_t WIFI_CONFIG::getSignal(int32_t RSSI)
-{
- if (RSSI <= -100) {
- return 0;
- }
- if (RSSI >= -50) {
- return 100;
- }
- return (2* (RSSI+100));
-}
-
-const char * WIFI_CONFIG::get_hostname()
-{
- String hname;
-#ifdef ARDUINO_ARCH_ESP8266
- hname = WiFi.hostname();
-#else
- hname = WiFi.getHostname();
-#endif
- if (hname.length()==0) {
- if (!CONFIG::read_string(EP_HOSTNAME, _hostname, MAX_HOSTNAME_LENGTH)) {
- strcpy(_hostname,get_default_hostname());
- }
- } else {
- strcpy(_hostname,hname.c_str());
- }
- return _hostname;
-}
-
-const char * WIFI_CONFIG::get_default_hostname()
-{
- static char hostname[13];
- uint8_t mac [WL_MAC_ADDR_LENGTH];
- WiFi.macAddress(mac);
- if (0>sprintf(hostname,"ESP_%02X%02X%02X",mac[3],mac[4],mac[5])) {
- strcpy (hostname, "ESP8266");
- }
- return hostname;
-}
-
-//safe setup if no connection
-void WIFI_CONFIG::Safe_Setup()
-{
-#ifdef CAPTIVE_PORTAL_FEATURE
- dnsServer.stop();
- delay(100);
-#endif
-
- WiFi.disconnect();
- //setup Soft AP
- WiFi.mode(WIFI_AP);
- IPAddress local_ip (DEFAULT_IP_VALUE[0],DEFAULT_IP_VALUE[1],DEFAULT_IP_VALUE[2],DEFAULT_IP_VALUE[3]);
- IPAddress gateway (DEFAULT_GATEWAY_VALUE[0],DEFAULT_GATEWAY_VALUE[1],DEFAULT_GATEWAY_VALUE[2],DEFAULT_GATEWAY_VALUE[3]);
- IPAddress subnet (DEFAULT_MASK_VALUE[0],DEFAULT_MASK_VALUE[1],DEFAULT_MASK_VALUE[2],DEFAULT_MASK_VALUE[3]);
- String ssid = FPSTR(DEFAULT_AP_SSID);
- String pwd = FPSTR(DEFAULT_AP_PASSWORD);
- WiFi.softAP(ssid.c_str(),pwd.c_str());
- delay(500);
- WiFi.softAPConfig( local_ip, gateway, subnet);
- delay(1000);
- ESP_SERIAL_OUT.println(F("M117 Safe mode started"));
-}
-
-//Read configuration settings and apply them
-bool WIFI_CONFIG::Setup(bool force_ap)
-{
- char pwd[MAX_PASSWORD_LENGTH+1];
- char sbuf[MAX_SSID_LENGTH+1];
- char hostname [MAX_HOSTNAME_LENGTH+1];
- //int wstatus;
- IPAddress currentIP;
- byte bflag=0;
- byte bmode=0;
- //system_update_cpu_freq(SYS_CPU_160MHZ);
- //set the sleep mode
- if (!CONFIG::read_byte(EP_SLEEP_MODE, &bflag )) {
- LOG("Error read Sleep mode\r\n")
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP8266
- WiFi.setSleepMode ((WiFiSleepType_t)bflag);
-#else
- esp_wifi_set_ps((wifi_ps_type_t)bflag);
-#endif
- sleep_mode=bflag;
- if (force_ap) {
- bmode = AP_MODE;
- } else {
- //AP or client ?
- if (!CONFIG::read_byte(EP_WIFI_MODE, &bmode ) ) {
- LOG("Error read wifi mode\r\n")
- return false;
- }
- }
- if (!CONFIG::read_string(EP_HOSTNAME, hostname, MAX_HOSTNAME_LENGTH)) {
- strcpy(hostname,get_default_hostname());
- }
- //this is AP mode
- if (bmode==AP_MODE) {
- LOG("Set AP mode\r\n")
- if(!CONFIG::read_string(EP_AP_SSID, sbuf, MAX_SSID_LENGTH)) {
- return false;
- }
- if(!CONFIG::read_string(EP_AP_PASSWORD, pwd, MAX_PASSWORD_LENGTH)) {
- return false;
- }
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.print(F("SSID "));
- ESP_SERIAL_OUT.println(sbuf);
- LOG("SSID ")
- LOG(sbuf)
- LOG("\r\n")
- //DHCP or Static IP ?
- if (!CONFIG::read_byte(EP_AP_IP_MODE, &bflag )) {
- LOG("Error IP mode\r\n")
- return false;
- }
- LOG("IP Mode: ")
- LOG(CONFIG::intTostr(bflag))
- LOG("\r\n")
- if (bflag==STATIC_IP_MODE) {
- byte ip_buf[4];
- LOG("Static mode\r\n")
- //get the IP
- LOG("IP value:")
- if (!CONFIG::read_buffer(EP_AP_IP_VALUE,ip_buf, IP_LENGTH)) {
- LOG("Error\r\n")
- return false;
- }
- IPAddress local_ip (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- LOG(local_ip.toString())
- LOG("\r\nGW value:")
- //get the gateway
- if (!CONFIG::read_buffer(EP_AP_GATEWAY_VALUE,ip_buf, IP_LENGTH)) {
- LOG("Error\r\n")
- return false;
- }
- IPAddress gateway (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- LOG(gateway.toString())
- LOG("\r\nMask value:")
- //get the mask
- if (!CONFIG::read_buffer(EP_AP_MASK_VALUE,ip_buf, IP_LENGTH)) {
- LOG("Error Mask value\r\n")
- return false;
- }
- IPAddress subnet (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- LOG(subnet.toString())
- LOG("\r\n")
- //apply according active wifi mode
- LOG("Set IP\r\n")
- WiFi.softAPConfig( local_ip, gateway, subnet);
- delay(100);
- }
- LOG("Disable STA\r\n")
- WiFi.enableSTA(false);
- delay(100);
- LOG("Set phy mode\r\n")
- //setup PHY_MODE
- if (!CONFIG::read_byte(EP_AP_PHY_MODE, &bflag )) {
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP32
- esp_wifi_set_protocol(ESP_IF_WIFI_AP, bflag);
-#endif
- LOG("Set AP\r\n")
- //setup Soft AP
- WiFi.mode(WIFI_AP);
- delay(50);
- WiFi.softAP(sbuf, pwd);
- delay(100);
-#ifdef ARDUINO_ARCH_ESP8266
- WiFi.setPhyMode((WiFiPhyMode_t)bflag);
-#endif
- delay(100);
- LOG("Get current config\r\n")
- //get current config
-#ifdef ARDUINO_ARCH_ESP32
- wifi_config_t conf;
- esp_wifi_get_config(ESP_IF_WIFI_AP, &conf);
-#else
- struct softap_config apconfig;
- wifi_softap_get_config(&apconfig);
-#endif
- //set the chanel
- if (!CONFIG::read_byte(EP_CHANNEL, &bflag )) {
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP32
- conf.ap.channel=bflag;
-#else
- apconfig.channel=bflag;
-#endif
- //set Authentification type
- if (!CONFIG::read_byte(EP_AUTH_TYPE, &bflag )) {
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP32
- conf.ap.authmode=(wifi_auth_mode_t)bflag;
-#else
- apconfig.authmode=(AUTH_MODE)bflag;
-#endif
- //set the visibility of SSID
- if (!CONFIG::read_byte(EP_SSID_VISIBLE, &bflag )) {
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP32
- conf.ap.ssid_hidden=!bflag;
-#else
- apconfig.ssid_hidden=!bflag;
-#endif
-
- //no need to add these settings to configuration just use default ones
-#ifdef ARDUINO_ARCH_ESP32
- conf.ap.max_connection=DEFAULT_MAX_CONNECTIONS;
- conf.ap.beacon_interval=DEFAULT_BEACON_INTERVAL;
- if (esp_wifi_set_config(ESP_IF_WIFI_AP, &conf)!=ESP_OK){
- ESP_SERIAL_OUT.println(F("M117 Error Wifi AP!"));
- delay(1000);
- }
-#else
- apconfig.max_connection=DEFAULT_MAX_CONNECTIONS;
- apconfig.beacon_interval=DEFAULT_BEACON_INTERVAL;
- //apply settings to current and to default
- if (!wifi_softap_set_config(&apconfig) || !wifi_softap_set_config_current(&apconfig)) {
- ESP_SERIAL_OUT.println(F("M117 Error Wifi AP!"));
- delay(1000);
- }
-#endif
- } else {
- LOG("Set STA mode\r\n")
- if(!CONFIG::read_string(EP_STA_SSID, sbuf, MAX_SSID_LENGTH)) {
- return false;
- }
- if(!CONFIG::read_string(EP_STA_PASSWORD, pwd, MAX_PASSWORD_LENGTH)) {
- return false;
- }
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.print(F("SSID "));
- ESP_SERIAL_OUT.println(sbuf);
- LOG("SSID ")
- LOG(sbuf)
- LOG("\r\n")
- if (!CONFIG::read_byte(EP_STA_IP_MODE, &bflag )) {
- return false;
- }
- if (bflag==STATIC_IP_MODE) {
- byte ip_buf[4];
- //get the IP
- if (!CONFIG::read_buffer(EP_STA_IP_VALUE,ip_buf, IP_LENGTH)) {
- return false;
- }
- IPAddress local_ip (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- //get the gateway
- if (!CONFIG::read_buffer(EP_STA_GATEWAY_VALUE,ip_buf, IP_LENGTH)) {
- return false;
- }
- IPAddress gateway (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- //get the mask
- if (!CONFIG::read_buffer(EP_STA_MASK_VALUE,ip_buf, IP_LENGTH)) {
- return false;
- }
- IPAddress subnet (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
- //apply according active wifi mode
- WiFi.config( local_ip, gateway, subnet);
- }
- WiFi.enableAP(false);
- delay(100);
- //setup PHY_MODE
- if (!CONFIG::read_byte(EP_STA_PHY_MODE, &bflag )) {
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP32
- esp_wifi_set_protocol(ESP_IF_WIFI_STA, bflag);
-#endif
- //setup station mode
- WiFi.mode(WIFI_STA);
- delay(100);
-#ifdef ARDUINO_ARCH_ESP8266
- WiFi.setPhyMode((WiFiPhyMode_t)bflag);
-#endif
- WiFi.begin(sbuf, pwd);
- delay(100);
- byte i=0;
- //try to connect
- byte dot = 0;
- String msg;
- while (WiFi.status() != WL_CONNECTED && i<40) {
- switch(WiFi.status()) {
- case 1:
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.println(F("No SSID found!"));
- break;
-
- case 4:
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.println(F("No Connection!"));
- break;
-
- default:
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- if (dot == 0)msg = F("Connecting");
- dot++;
- msg.trim();
- msg +=F(".");
- //for smoothieware to keep position
- for (byte i= 0;i< 4-dot; i++)msg +=F(" ");
- if (dot == 4)dot=0;
- ESP_SERIAL_OUT.println(msg);
- break;
- }
- delay(500);
- i++;
- }
- if (WiFi.status() != WL_CONNECTED) {
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.println(F("Not Connectied!"));
- return false;
- }
-#ifdef ARDUINO_ARCH_ESP8266
- WiFi.hostname(hostname);
-#else
- WiFi.setHostname(hostname);
-#endif
- }
-
- //Get IP
- if (WiFi.getMode()==WIFI_STA) {
- currentIP=WiFi.localIP();
- } else {
- currentIP=WiFi.softAPIP();
- }
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.println(currentIP);
- ESP_SERIAL_OUT.flush();
- return true;
-}
-
-bool WIFI_CONFIG::Enable_servers()
-{
- //start web interface
- web_interface = new WEBINTERFACE_CLASS(wifi_config.iweb_port);
- //here the list of headers to be recorded
- const char * headerkeys[] = {"Cookie"} ;
- size_t headerkeyssize = sizeof(headerkeys)/sizeof(char*);
- //ask server to track these headers
- web_interface->web_server.collectHeaders(headerkeys, headerkeyssize );
-#ifdef CAPTIVE_PORTAL_FEATURE
- if (WiFi.getMode()!=WIFI_STA ) {
- // if DNSServer is started with "*" for domain name, it will reply with
- // provided IP to all DNS request
- dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
- dnsServer.start(DNS_PORT, "*", WiFi.softAPIP());
- }
-#endif
- web_interface->web_server.begin();
-#ifdef TCP_IP_DATA_FEATURE
- //start TCP/IP interface
- data_server = new WiFiServer (wifi_config.idata_port);
- data_server->begin();
- data_server->setNoDelay(true);
-#endif
-
-#ifdef MDNS_FEATURE
- // Set up mDNS responder:
- //useless in AP mode and service consuming
- if (WiFi.getMode()!=WIFI_AP ){
- char hostname [MAX_HOSTNAME_LENGTH+1];
- if (!CONFIG::read_string(EP_HOSTNAME, hostname, MAX_HOSTNAME_LENGTH)) {
- strcpy(hostname,get_default_hostname());
- }
- if (!mdns.begin(hostname)) {
- ESP_SERIAL_OUT.print(FPSTR(M117_));
- ESP_SERIAL_OUT.println(F("Error with mDNS!"));
- delay(1000);
- } else {
- // Check for any mDNS queries and send responses
- delay(100);
- wifi_config.mdns.addService("http", "tcp", wifi_config.iweb_port);
- }
- }
-#endif
-#if defined(SSDP_FEATURE) || defined(NETBIOS_FEATURE)
- String shost;
- if (!CONFIG::read_string(EP_HOSTNAME, shost, MAX_HOSTNAME_LENGTH)) {
- shost=wifi_config.get_default_hostname();
- }
-#endif
-#ifdef SSDP_FEATURE
- String stmp;
- SSDP.setSchemaURL("description.xml");
- SSDP.setHTTPPort( wifi_config.iweb_port);
- SSDP.setName(shost.c_str());
- stmp=String(ESP.getChipId());
- SSDP.setSerialNumber(stmp.c_str());
- SSDP.setURL("/");
- SSDP.setModelName("ESP8266 01");
- SSDP.setModelNumber("01");
- SSDP.setModelURL("http://espressif.com/en/products/esp8266/");
- SSDP.setManufacturer("Espressif Systems");
- SSDP.setManufacturerURL("http://espressif.com");
- SSDP.setDeviceType("upnp:rootdevice");
- if (WiFi.getMode()!=WIFI_AP )SSDP.begin();
-#endif
-#ifdef NETBIOS_FEATURE
- //useless in AP mode and service consuming
- if (WiFi.getMode()!=WIFI_AP )NBNS.begin(shost.c_str());
-#endif
-
- return true;
-}
-
-bool WIFI_CONFIG::Disable_servers()
-{
-#ifdef TCP_IP_DATA_FEATURE
- data_server->stop();
-#endif
-#ifdef CAPTIVE_PORTAL_FEATURE
- if (WiFi.getMode()!=WIFI_STA ) {
- dnsServer.stop();
- }
-#endif
-#ifdef NETBIOS_FEATURE
- //useless in AP mode and service consuming
- if (WiFi.getMode()!=WIFI_AP )NBNS.end();
-#endif
- web_interface->web_server.stop();
- return true;
-}
-
-WIFI_CONFIG wifi_config;
diff --git a/esp3d/wificonf.h b/esp3d/wificonf.h
deleted file mode 100644
index 603bbd4c..00000000
--- a/esp3d/wificonf.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- wificonf.h - ESP3D configuration class
-
- Copyright (c) 2014 Luc Lebosse. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef WIFICONF_H
-#define WIFICONF_H
-#include
-#include "config.h"
-#include "IPAddress.h"
-#ifdef ARDUINO_ARCH_ESP8266
-#include "ESP8266WiFi.h"
-#ifdef MDNS_FEATURE
-#include
-#endif
-#else
-#include
-#ifdef MDNS_FEATURE
-#include
-#endif
-#endif
-
-class WIFI_CONFIG
-{
-public:
- // multicast DNS responder feature
-#ifdef MDNS_FEATURE
- MDNSResponder mdns;
-#endif
- WIFI_CONFIG();
- int iweb_port;
- int idata_port;
- long baud_rate;
- int sleep_mode;
- int32_t getSignal(int32_t RSSI);
- bool Setup(bool force_ap = false);
- void Safe_Setup();
- bool Enable_servers();
- bool Disable_servers();
- const char * get_default_hostname();
- const char * get_hostname();
-private:
- char _hostname[33];
-};
-
-extern WIFI_CONFIG wifi_config;
-#endif
diff --git a/libraries/WebServer/.gitignore b/libraries/WebServer/.gitignore
deleted file mode 100644
index 259148fa..00000000
--- a/libraries/WebServer/.gitignore
+++ /dev/null
@@ -1,32 +0,0 @@
-# Prerequisites
-*.d
-
-# Compiled Object files
-*.slo
-*.lo
-*.o
-*.obj
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Compiled Dynamic libraries
-*.so
-*.dylib
-*.dll
-
-# Fortran module files
-*.mod
-*.smod
-
-# Compiled Static libraries
-*.lai
-*.la
-*.a
-*.lib
-
-# Executables
-*.exe
-*.out
-*.app
diff --git a/libraries/WebServer/.travis.yml b/libraries/WebServer/.travis.yml
deleted file mode 100644
index 3c0d1d70..00000000
--- a/libraries/WebServer/.travis.yml
+++ /dev/null
@@ -1,99 +0,0 @@
-sudo: false
-
-language: python
-python:
- - "2.7"
-
-os:
- - linux
-
-env:
- - TESTCASE="1.8.3|esp8266|stable|esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M"
- - TESTCASE="1.8.3|esp8266|devel|esp8266com:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M"
- - TESTCASE="1.8.3|esp32|devel|espressif:esp32:esp32:FlashFreq=40"
-
-script:
- - echo -e "travis_fold:start:sketch_test_env_prepare"
- - pip install pyserial
- - IFS='|' read -r -a array <<< "${TESTCASE}"
- - |
- for index in "${!array[@]}"
- do
- case $index in
- 0) IDEVER="${array[index]}" ;;
- 1) PLATFORM="${array[index]}" ;;
- 2) RELEASE="${array[index]}" ;;
- 3) BOARD="${array[index]}" ;;
- esac
- done
- - cd $HOME
- - wget -O arduino.tar.xz https://downloads.arduino.cc/arduino-${IDEVER}-linux64.tar.xz
- - tar xf arduino.tar.xz
- - mv arduino-${IDEVER} $HOME/arduino_ide
- - mkdir -p $HOME/Arduino/libraries
- - IDEDIR="${HOME}/arduino_ide"
- - export PATH="$IDEDIR:$PATH"
- - cd ${IDEDIR}
- - which arduino
- - |
- if [[ $PLATFORM == "esp8266" ]] && [[ $RELEASE == "stable" ]]
- then
- arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs
- arduino --install-boards "esp8266:esp8266"
- fi
- - |
- if [[ $PLATFORM == "esp8266" ]] && [[ $RELEASE == "devel" ]]
- then
- mkdir -p hardware/esp8266com
- cd hardware/esp8266com
- git clone https://github.com/esp8266/Arduino.git esp8266
- cd esp8266/tools
- python get.py
- fi
- - |
- if [[ $PLATFORM == "esp32" ]] && [[ $RELEASE == "devel" ]]
- then
- mkdir -p hardware/espressif
- cd hardware/espressif
- git clone https://github.com/espressif/arduino-esp32.git esp32
- cd esp32/tools/
- python get.py
- fi
- - arduino --pref "compiler.warning_level=all" --save-prefs
- - echo -e "travis_fold:end:sketch_test_env_prepare"
- - echo -e "travis_fold:start:install_library"
- - cd $HOME/Arduino/libraries
- - git clone https://github.com/bbx10/WebServer_tng ${HOME}/Arduino/libraries/WebServer
- - echo -e "travis_fold:end:install_library"
- - echo -e "travis_fold:start:AdvancedWebServer"
- - cd ${HOME}/Arduino/libraries/WebServer/examples
- - arduino --verbose-build --verify --board ${BOARD} AdvancedWebServer/AdvancedWebServer.ino
- - echo -e "travis_fold:end:AdvancedWebServer"
- - echo -e "travis_fold:start:HelloServer"
- - arduino --verbose-build --verify --board ${BOARD} HelloServer/HelloServer.ino
- - echo -e "travis_fold:end:HelloServer"
- - echo -e "travis_fold:start:HttpBasicAuth"
- - arduino --verbose-build --verify --board ${BOARD} HttpBasicAuth/HttpBasicAuth.ino
- - echo -e "travis_fold:end:HttpBasicAuth"
- - echo -e "travis_fold:start:SDWebServer"
- - arduino --verbose-build --verify --board ${BOARD} SDWebServer/SDWebServer.ino
- - echo -e "travis_fold:end:SDWebServer"
- - echo -e "travis_fold:start:SimpleAuthentification"
- - arduino --verbose-build --verify --board ${BOARD} SimpleAuthentification/SimpleAuthentification.ino
- - echo -e "travis_fold:end:SimpleAuthentification"
- - |
- if [[ $PLATFORM == "esp8266" ]]
- then
- echo -e "travis_fold:start:FSBrowser"
- arduino --verbose-build --verify --board ${BOARD} FSBrowser/FSBrowser.ino
- echo -e "travis_fold:end:FSBrowser"
- echo -e "travis_fold:start:WebUpdate"
- arduino --verbose-build --verify --board ${BOARD} WebUpdate/WebUpdate.ino
- echo -e "travis_fold:end:WebUpdate"
- fi
-
-notifications:
- email:
- on_success: change
- on_failure: change
-
diff --git a/libraries/WebServer/LICENSE b/libraries/WebServer/LICENSE
deleted file mode 100644
index 19e30718..00000000
--- a/libraries/WebServer/LICENSE
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-(This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.)
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- {description}
- Copyright (C) {year} {fullname}
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random
- Hacker.
-
- {signature of Ty Coon}, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/libraries/WebServer/README.md b/libraries/WebServer/README.md
deleted file mode 100644
index 5ec07c51..00000000
--- a/libraries/WebServer/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# WebServer
-ESP8266/ESP32 WebServer library
-
-This is an experimental port of the ESP8266WebServer library that should work
-on ESP8266 and ESP32. This is NOT an official repo supported by Espressif. Do
-not depend on this code for anything important or expect it to be updated. Once
-the official repo is created, this repo will be deleted.
-
-Added Travis CI
diff --git a/libraries/WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino b/libraries/WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
deleted file mode 100644
index b46b101d..00000000
--- a/libraries/WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2015, Majenko Technologies
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * 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.
- *
- * * Neither the name of Majenko Technologies nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
- */
-
-#ifdef ESP8266
-#include
-#include
-#include
-#include
-ESP8266WebServer server ( 80 );
-#else
-#include
-#include
-#include
-#include
-WebServer server ( 80 );
-#endif
-
-const char *ssid = "YourSSIDHere";
-const char *password = "YourPSKHere";
-
-#ifdef LED_BUILTIN
-const int led = LED_BUILTIN;
-#else
-const int led = 13;
-#endif
-
-void handleRoot() {
- digitalWrite ( led, 1 );
- char temp[400];
- int sec = millis() / 1000;
- int min = sec / 60;
- int hr = min / 60;
-
- snprintf ( temp, 400,
-
-"\
- \
- \
- ESP8266/ESP32 Demo\
- \
- \
- \
-
Hello from ESP8266/ESP32!
\
-
Uptime: %02d:%02d:%02d
\
- \
- \
-",
-
- hr, min % 60, sec % 60
- );
- server.send ( 200, "text/html", temp );
- digitalWrite ( led, 0 );
-}
-
-void handleNotFound() {
- digitalWrite ( led, 1 );
- String message = "File Not Found\n\n";
- message += "URI: ";
- message += server.uri();
- message += "\nMethod: ";
- message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
- message += "\nArguments: ";
- message += server.args();
- message += "\n";
-
- for ( uint8_t i = 0; i < server.args(); i++ ) {
- message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
- }
-
- server.send ( 404, "text/plain", message );
- digitalWrite ( led, 0 );
-}
-
-void setup ( void ) {
- pinMode ( led, OUTPUT );
- digitalWrite ( led, 0 );
- Serial.begin ( 115200 );
- WiFi.begin ( ssid, password );
- Serial.println ( "" );
-
- // Wait for connection
- while ( WiFi.status() != WL_CONNECTED ) {
- delay ( 500 );
- Serial.print ( "." );
- }
-
- Serial.println ( "" );
- Serial.print ( "Connected to " );
- Serial.println ( ssid );
- Serial.print ( "IP address: " );
- Serial.println ( WiFi.localIP() );
-
-#ifdef ESP8266
- if ( MDNS.begin ( "esp8266" ) ) {
-#else
- if ( MDNS.begin ( "esp32" ) ) {
-#endif
- Serial.println ( "MDNS responder started" );
- }
-
- server.on ( "/", handleRoot );
- server.on ( "/test.svg", drawGraph );
- server.on ( "/inline", []() {
- server.send ( 200, "text/plain", "this works as well" );
- } );
- server.onNotFound ( handleNotFound );
- server.begin();
- Serial.println ( "HTTP server started" );
-}
-
-void loop ( void ) {
- server.handleClient();
-}
-
-void drawGraph() {
- String out = "";
- char temp[100];
- out += "\n";
-
- server.send ( 200, "image/svg+xml", out);
-}
diff --git a/libraries/WebServer/examples/FSBrowser/FSBrowser.ino b/libraries/WebServer/examples/FSBrowser/FSBrowser.ino
deleted file mode 100644
index e4cea8a1..00000000
--- a/libraries/WebServer/examples/FSBrowser/FSBrowser.ino
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- FSWebServer - Example WebServer with SPIFFS backend for esp8266
- Copyright (c) 2015 Hristo Gochkov. All rights reserved.
- This file is part of the ESP8266/ESP32 WebServer library for Arduino environment.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
- upload the contents of the data folder with MkSPIFFS Tool ("ESP8266 Sketch Data Upload" in Tools menu in Arduino IDE)
- or you can upload the contents of a folder if you CD in that folder and run the following command:
- for file in `ls -A1`; do curl -F "file=@$PWD/$file" esp8266fs.local/edit; done
-
- access the sample web page at http://esp8266fs.local
- edit the page by going to http://esp8266fs.local/edit
-*/
-/*
- * Uploading html, css, javascript, etc.
- * Use curl to upload the files from the SPIFFS data directory.
- * cd data/
- * curl -X POST -F "data=@index.htm" http:///edit >/dev/null
- * curl -X POST -F "data=@graphs.js.gz" http:///edit >/dev/null
- * curl -X POST -F "data=@favicon.ico" http:///edit >/dev/null
- * curl -X POST -F "data=@edit.htm.gz" http:///edit >/dev/null
- */
-#ifdef ESP8266
-#include
-#include
-#include
-#include
-#include
-ESP8266WebServer server(80);
-#else
-#include
-#include
-#include
-#include
-#include
-WebServer server(80);
-#endif
-
-#define DBG_OUTPUT_PORT Serial
-
-const char* ssid = "wifi-ssid";
-const char* password = "wifi-password";
-const char* host = "esp8266fs";
-
-//holds the current upload
-File fsUploadFile;
-
-//format bytes
-String formatBytes(size_t bytes){
- if (bytes < 1024){
- return String(bytes)+"B";
- } else if(bytes < (1024 * 1024)){
- return String(bytes/1024.0)+"KB";
- } else if(bytes < (1024 * 1024 * 1024)){
- return String(bytes/1024.0/1024.0)+"MB";
- } else {
- return String(bytes/1024.0/1024.0/1024.0)+"GB";
- }
-}
-
-String getContentType(String filename){
- if(server.hasArg("download")) return "application/octet-stream";
- else if(filename.endsWith(".htm")) return "text/html";
- else if(filename.endsWith(".html")) return "text/html";
- else if(filename.endsWith(".css")) return "text/css";
- else if(filename.endsWith(".js")) return "application/javascript";
- else if(filename.endsWith(".png")) return "image/png";
- else if(filename.endsWith(".gif")) return "image/gif";
- else if(filename.endsWith(".jpg")) return "image/jpeg";
- else if(filename.endsWith(".ico")) return "image/x-icon";
- else if(filename.endsWith(".xml")) return "text/xml";
- else if(filename.endsWith(".pdf")) return "application/x-pdf";
- else if(filename.endsWith(".zip")) return "application/x-zip";
- else if(filename.endsWith(".gz")) return "application/x-gzip";
- return "text/plain";
-}
-
-bool handleFileRead(String path){
- DBG_OUTPUT_PORT.println("handleFileRead: " + path);
- if(path.endsWith("/")) path += "index.htm";
- String contentType = getContentType(path);
- String pathWithGz = path + ".gz";
- if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){
- if(SPIFFS.exists(pathWithGz))
- path += ".gz";
- File file = SPIFFS.open(path, "r");
- size_t sent = server.streamFile(file, contentType);
- file.close();
- return true;
- }
- return false;
-}
-
-void handleFileUpload(){
- if(server.uri() != "/edit") return;
- HTTPUpload& upload = server.upload();
- if(upload.status == UPLOAD_FILE_START){
- String filename = upload.filename;
- if(!filename.startsWith("/")) filename = "/"+filename;
- DBG_OUTPUT_PORT.print("handleFileUpload Name: "); DBG_OUTPUT_PORT.println(filename);
- fsUploadFile = SPIFFS.open(filename, "w");
- filename = String();
- } else if(upload.status == UPLOAD_FILE_WRITE){
- //DBG_OUTPUT_PORT.print("handleFileUpload Data: "); DBG_OUTPUT_PORT.println(upload.currentSize);
- if(fsUploadFile)
- fsUploadFile.write(upload.buf, upload.currentSize);
- } else if(upload.status == UPLOAD_FILE_END){
- if(fsUploadFile)
- fsUploadFile.close();
- DBG_OUTPUT_PORT.print("handleFileUpload Size: "); DBG_OUTPUT_PORT.println(upload.totalSize);
- }
-}
-
-void handleFileDelete(){
- if(server.args() == 0) return server.send(500, "text/plain", "BAD ARGS");
- String path = server.arg(0);
- DBG_OUTPUT_PORT.println("handleFileDelete: " + path);
- if(path == "/")
- return server.send(500, "text/plain", "BAD PATH");
- if(!SPIFFS.exists(path))
- return server.send(404, "text/plain", "FileNotFound");
- SPIFFS.remove(path);
- server.send(200, "text/plain", "");
- path = String();
-}
-
-void handleFileCreate(){
- if(server.args() == 0)
- return server.send(500, "text/plain", "BAD ARGS");
- String path = server.arg(0);
- DBG_OUTPUT_PORT.println("handleFileCreate: " + path);
- if(path == "/")
- return server.send(500, "text/plain", "BAD PATH");
- if(SPIFFS.exists(path))
- return server.send(500, "text/plain", "FILE EXISTS");
- File file = SPIFFS.open(path, "w");
- if(file)
- file.close();
- else
- return server.send(500, "text/plain", "CREATE FAILED");
- server.send(200, "text/plain", "");
- path = String();
-}
-
-void returnFail(String msg) {
- server.send(500, "text/plain", msg + "\r\n");
-}
-
-#ifdef ESP8266
-void handleFileList() {
- if(!server.hasArg("dir")) {
- returnFail("BAD ARGS");
- return;
- }
-
- String path = server.arg("dir");
- DBG_OUTPUT_PORT.println("handleFileList: " + path);
- Dir dir = SPIFFS.openDir(path);
- path = String();
-
- String output = "[";
- while(dir.next()){
- File entry = dir.openFile("r");
- if (output != "[") output += ',';
- bool isDir = false;
- output += "{\"type\":\"";
- output += (isDir)?"dir":"file";
- output += "\",\"name\":\"";
- output += String(entry.name()).substring(1);
- output += "\"}";
- entry.close();
- }
-
- output += "]";
- server.send(200, "text/json", output);
-}
-#else
-void handleFileList() {
- if(!server.hasArg("dir")) {
- returnFail("BAD ARGS");
- return;
- }
- String path = server.arg("dir");
- if(path != "/" && !SPIFFS.exists((char *)path.c_str())) {
- returnFail("BAD PATH");
- return;
- }
- File dir = SPIFFS.open((char *)path.c_str());
- path = String();
- if(!dir.isDirectory()){
- dir.close();
- returnFail("NOT DIR");
- return;
- }
- dir.rewindDirectory();
-
- String output = "[";
- for (int cnt = 0; true; ++cnt) {
- File entry = dir.openNextFile();
- if (!entry)
- break;
-
- if (cnt > 0)
- output += ',';
-
- output += "{\"type\":\"";
- output += (entry.isDirectory()) ? "dir" : "file";
- output += "\",\"name\":\"";
- // Ignore '/' prefix
- output += entry.name()+1;
- output += "\"";
- output += "}";
- entry.close();
- }
- output += "]";
- server.send(200, "text/json", output);
- dir.close();
-}
-
-void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
- DBG_OUTPUT_PORT.printf("Listing directory: %s\n", dirname);
-
- File root = fs.open(dirname);
- if (!root) {
- DBG_OUTPUT_PORT.println("Failed to open directory");
- return;
- }
- if (!root.isDirectory()) {
- DBG_OUTPUT_PORT.println("Not a directory");
- return;
- }
-
- File file = root.openNextFile();
- while (file) {
- if (file.isDirectory()) {
- DBG_OUTPUT_PORT.print(" DIR : ");
- DBG_OUTPUT_PORT.println(file.name());
- if (levels) {
- listDir(fs, file.name(), levels - 1);
- }
- } else {
- DBG_OUTPUT_PORT.print(" FILE: ");
- DBG_OUTPUT_PORT.print(file.name());
- DBG_OUTPUT_PORT.print(" SIZE: ");
- DBG_OUTPUT_PORT.println(file.size());
- }
- file = root.openNextFile();
- }
-}
-#endif
-
-
-void setup(void){
- DBG_OUTPUT_PORT.begin(115200);
- DBG_OUTPUT_PORT.print("\n");
- DBG_OUTPUT_PORT.setDebugOutput(true);
- SPIFFS.begin();
- {
-#ifdef ESP8266
- Dir dir = SPIFFS.openDir("/");
- while (dir.next()) {
- String fileName = dir.fileName();
- size_t fileSize = dir.fileSize();
- DBG_OUTPUT_PORT.printf("FS File: %s, size: %s\n", fileName.c_str(), formatBytes(fileSize).c_str());
- }
-#else
- listDir(SPIFFS, "/", 0);
-#endif
- DBG_OUTPUT_PORT.printf("\n");
- }
-
-
- //WIFI INIT
- DBG_OUTPUT_PORT.printf("Connecting to %s\n", ssid);
- if (String(WiFi.SSID()) != String(ssid)) {
- WiFi.begin(ssid, password);
- }
-
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- DBG_OUTPUT_PORT.print(".");
- }
- DBG_OUTPUT_PORT.println("");
- DBG_OUTPUT_PORT.print("Connected! IP address: ");
- DBG_OUTPUT_PORT.println(WiFi.localIP());
-
- MDNS.begin(host);
- DBG_OUTPUT_PORT.print("Open http://");
- DBG_OUTPUT_PORT.print(host);
- DBG_OUTPUT_PORT.println(".local/edit to see the file browser");
-
-
- //SERVER INIT
- //list directory
- server.on("/list", HTTP_GET, handleFileList);
- //load editor
- server.on("/edit", HTTP_GET, [](){
- if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound");
- });
- //create file
- server.on("/edit", HTTP_PUT, handleFileCreate);
- //delete file
- server.on("/edit", HTTP_DELETE, handleFileDelete);
- //first callback is called after the request has ended with all parsed arguments
- //second callback handles file uploads at that location
- server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);
-
- //called when the url is not defined here
- //use it to load content from SPIFFS
- server.onNotFound([](){
- if(!handleFileRead(server.uri()))
- server.send(404, "text/plain", "FileNotFound");
- });
-
- //get heap status, analog input value and all GPIO statuses in one json call
- server.on("/all", HTTP_GET, [](){
- String json = "{";
- json += "\"heap\":"+String(ESP.getFreeHeap());
- json += ", \"analog\":"+String(analogRead(A0));
-#ifdef ESP8266
- json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
-#endif
- json += "}";
- server.send(200, "text/json", json);
- json = String();
- });
- server.begin();
- DBG_OUTPUT_PORT.println("HTTP server started");
-
-}
-
-void loop(void){
- server.handleClient();
-}
diff --git a/libraries/WebServer/examples/FSBrowser/data/edit.htm.gz b/libraries/WebServer/examples/FSBrowser/data/edit.htm.gz
deleted file mode 100644
index 69ce414f..00000000
Binary files a/libraries/WebServer/examples/FSBrowser/data/edit.htm.gz and /dev/null differ
diff --git a/libraries/WebServer/examples/FSBrowser/data/favicon.ico b/libraries/WebServer/examples/FSBrowser/data/favicon.ico
deleted file mode 100644
index 71b25fe6..00000000
Binary files a/libraries/WebServer/examples/FSBrowser/data/favicon.ico and /dev/null differ
diff --git a/libraries/WebServer/examples/FSBrowser/data/graphs.js.gz b/libraries/WebServer/examples/FSBrowser/data/graphs.js.gz
deleted file mode 100644
index 72435445..00000000
Binary files a/libraries/WebServer/examples/FSBrowser/data/graphs.js.gz and /dev/null differ
diff --git a/libraries/WebServer/examples/FSBrowser/data/index.htm b/libraries/WebServer/examples/FSBrowser/data/index.htm
deleted file mode 100644
index 4e1dc7d9..00000000
--- a/libraries/WebServer/examples/FSBrowser/data/index.htm
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
- ESP Monitor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/libraries/WebServer/examples/HelloServer/HelloServer.ino b/libraries/WebServer/examples/HelloServer/HelloServer.ino
deleted file mode 100644
index f5390364..00000000
--- a/libraries/WebServer/examples/HelloServer/HelloServer.ino
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifdef ESP8266
-#include
-#include
-#include
-#include
-ESP8266WebServer server(80);
-#else
-#include
-#include
-#include
-#include
-WebServer server(80);
-#endif
-
-const char* ssid = "........";
-const char* password = "........";
-
-#ifdef LED_BUILTIN
-const int led = LED_BUILTIN;
-#else
-const int led = 13;
-#endif
-
-void handleRoot() {
- digitalWrite(led, 1);
-#ifdef ESP8266
- server.send(200, "text/plain", "hello from esp8266!");
-#else
- server.send(200, "text/plain", "hello from esp32!");
-#endif
- digitalWrite(led, 0);
-}
-
-void handleNotFound(){
- digitalWrite(led, 1);
- String message = "File Not Found\n\n";
- message += "URI: ";
- message += server.uri();
- message += "\nMethod: ";
- message += (server.method() == HTTP_GET)?"GET":"POST";
- message += "\nArguments: ";
- message += server.args();
- message += "\n";
- for (uint8_t i=0; i
-#include
-#include
-#include
-ESP8266WebServer server(80);
-#else
-#include
-#include
-#include
-#include
-WebServer server(80);
-#endif
-
-const char* ssid = "........";
-const char* password = "........";
-
-const char* www_username = "admin";
-const char* www_password = "esp8266esp32";
-
-void setup() {
- Serial.begin(115200);
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- if(WiFi.waitForConnectResult() != WL_CONNECTED) {
- Serial.println("WiFi Connect Failed! Rebooting...");
- delay(1000);
- ESP.restart();
- }
- ArduinoOTA.begin();
-
- server.on("/", [](){
- if(!server.authenticate(www_username, www_password))
- return server.requestAuthentication();
- server.send(200, "text/plain", "Login OK");
- });
- server.begin();
-
- Serial.print("Open http://");
- Serial.print(WiFi.localIP());
- Serial.println("/ in your browser to see it working");
-}
-
-void loop() {
- ArduinoOTA.handle();
- server.handleClient();
-}
diff --git a/libraries/WebServer/examples/SDWebServer/SDWebServer.ino b/libraries/WebServer/examples/SDWebServer/SDWebServer.ino
deleted file mode 100644
index 4234a880..00000000
--- a/libraries/WebServer/examples/SDWebServer/SDWebServer.ino
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- SDWebServer - Example WebServer with SD Card backend for esp8266/esp32
-
- Copyright (c) 2015 Hristo Gochkov. All rights reserved.
- This file is part of the ESP8266/ESP32 WebServer library for Arduino environment.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
- Have a FAT Formatted SD Card connected to the SPI port of the ESP8266
- The web root is the SD Card root folder
- File extensions with more than 3 charecters are not supported by the SD Library
- File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter
- index.htm is the default index (works on subfolders as well)
-
- upload the contents of SdRoot to the root of the SDcard and access the editor by going to http://esp8266sd.local/edit
-
-*/
-#ifdef ESP8266
-#include
-#include
-#include
-#include
-#include