forked from rvdbreemen/OTGW-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTGW-ModUpdateServer.h
89 lines (70 loc) · 2.53 KB
/
OTGW-ModUpdateServer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
***************************************************************************
** Program : OTGW-MonUpdateServer.h
** Modified to work with OTGW Nodoshop Hardware Watchdog
**
** This is the ESP8266HTTPUpdateServer.h file
** Created and modified by Ivan Grokhotkov, Miguel Angel Ajo, Earle Philhower and many others
** see: https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266HTTPUpdateServer
**
** ... and then modified by Willem Aandewiel
**
** License and credits
** Arduino IDE is developed and maintained by the Arduino team. The IDE is licensed under GPL.
**
** ESP8266 core includes an xtensa gcc toolchain, which is also under GPL.
**
***************************************************************************
*/
#ifndef __HTTP_UPDATE_SERVER_H
#define __HTTP_UPDATE_SERVER_H
#include <ESP8266WebServer.h>
namespace esp8266httpupdateserver {
using namespace esp8266webserver;
template <typename ServerType>
class ESP8266HTTPUpdateServerTemplate
{
public:
ESP8266HTTPUpdateServerTemplate(bool serial_debug=false);
void setup(ESP8266WebServerTemplate<ServerType> *server)
{
setup(server, emptyString, emptyString);
}
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& path)
{
setup(server, path, emptyString, emptyString);
}
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& username, const String& password)
{
setup(server, "/update", username, password);
}
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& path, const String& username, const String& password);
void updateCredentials(const String& username, const String& password)
{
_username = username;
_password = password;
}
void setIndexPage(const char *indexPage);
void setSuccessPage(const char *succesPage);
protected:
void _setUpdaterError();
private:
bool _serial_output;
ESP8266WebServerTemplate<ServerType> *_server;
String _username;
String _password;
bool _authenticated;
String _updaterError;
const char *_serverIndex;
const char *_serverSuccess;
};
};
#include "OTGW-ModUpdateServer-impl.h"
using ESP8266HTTPUpdateServer = esp8266httpupdateserver::ESP8266HTTPUpdateServerTemplate<WiFiServer>;
namespace BearSSL {
using ESP8266HTTPUpdateServerSecure = esp8266httpupdateserver::ESP8266HTTPUpdateServerTemplate<WiFiServerSecure>;
};
namespace axTLS {
using ESP8266HTTPUpdateServerSecure = esp8266httpupdateserver::ESP8266HTTPUpdateServerTemplate<WiFiServerSecure>;
};
#endif