ESP3D  3.0
Firmware for ESP boards connected to 3D Printer
http_server.h
Go to the documentation of this file.
1 /*
2  http_server.h - http server functions class
3 
4  Copyright (c) 2014 Luc Lebosse. All rights reserved.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 
22 #ifndef _HTTP_SERVER_H
23 #define _HTTP_SERVER_H
24 #include "../../include/esp3d_config.h"
25 //class WebSocketsServer;
26 #if defined (ARDUINO_ARCH_ESP32)
27 class WebServer;
28 #define WEBSERVER WebServer
29 #endif //ARDUINO_ARCH_ESP32
30 #if defined (ARDUINO_ARCH_ESP8266)
31 #include <ESP8266WebServer.h>
32 #define WEBSERVER ESP8266WebServer
33 #endif //ARDUINO_ARCH_ESP8266
34 
35 
36 //Upload status
37 typedef enum {
44 
46 {
47 public:
48  HTTP_Server();
49  ~HTTP_Server();
50  static bool begin();
51  static void end();
52  static void handle();
53  static bool started()
54  {
55  return _started;
56  }
57  static uint16_t port()
58  {
59  return _port;
60  }
61 private:
62  static void pushError(int code, const char * st, bool web_error = 500, uint16_t timeout = 1000);
63  static void cancelUpload();
64  static bool _started;
65  static WEBSERVER * _webserver;
66  static uint16_t _port;
67  static uint8_t _upload_status;
68  static const char * getContentType (const char * filename);
69  static const char * get_Splited_Value(String data, char separator, int index);
70 #ifdef SSDP_FEATURE
71  static void handle_SSDP ();
72 #endif //SSDP_FEATURE
73  static void init_handlers();
74  static bool StreamFSFile(const char* filename, const char * contentType);
75  static void handle_root();
76  static void handle_login();
77  static void handle_not_found ();
78  static void handle_web_command ();
79  static void handle_config ();
80  // static void handle_Websocket_Event(uint8_t num, uint8_t type, uint8_t * payload, size_t length);
81 #ifdef FILESYSTEM_FEATURE
82  static void FSFileupload ();
83  static void handleFSFileList ();
84 #endif //FILESYSTEM_FEATURE
85 #ifdef WEB_UPDATE_FEATURE
86  static void handleUpdate ();
87  static void WebUpdateUpload ();
88 #endif //WEB_UPDATE_FEATURE
89  //static bool is_realtime_cmd(char c);
90 #ifdef SD_DEVICE
91  static void SDFileupload ();
92  static void handleSDFileList ();
93 #endif //SD_DEVICE
94 };
95 
96 #endif //_HTTP_SERVER_H
97 
HTTP_Server::~HTTP_Server
~HTTP_Server()
Definition: http_server.cpp:45
HTTP_Server::begin
static bool begin()
Definition: http_server.cpp:155
HTTP_Server
Definition: http_server.h:45
UPLOAD_STATUS_FAILED
@ UPLOAD_STATUS_FAILED
Definition: http_server.h:39
UPLOAD_STATUS_ONGOING
@ UPLOAD_STATUS_ONGOING
Definition: http_server.h:42
UPLOAD_STATUS_CANCELLED
@ UPLOAD_STATUS_CANCELLED
Definition: http_server.h:40
HTTP_Server::end
static void end()
Definition: http_server.cpp:186
UPLOAD_STATUS_NONE
@ UPLOAD_STATUS_NONE
Definition: http_server.h:38
HTTP_Server::port
static uint16_t port()
Definition: http_server.h:57
HTTP_Server::HTTP_Server
HTTP_Server()
Definition: http_server.cpp:42
upload_status_type
upload_status_type
Definition: http_server.h:37
HTTP_Server::started
static bool started()
Definition: http_server.h:53
HTTP_Server::handle
static void handle()
Definition: http_server.cpp:200
UPLOAD_STATUS_SUCCESSFUL
@ UPLOAD_STATUS_SUCCESSFUL
Definition: http_server.h:41