Allow to disable FW web update when compiling

New compilation directive to enable/disable feature
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
#define WEB_UPDATE_FEATURE
This commit is contained in:
Luc 2016-01-26 11:50:02 +08:00
parent 70228adb3d
commit 75ebd04d12
5 changed files with 24 additions and 6 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
Thumbs.db
Thumbs.db
*.orig

View File

@ -435,5 +435,11 @@ void CONFIG::print_config()
Serial.println(F("Enabled"));
#else
Serial.println(F("Disabled"));
#endif
Serial.print(F("Web update: "));
#ifdef WEB_UPDATE_FEATURE
Serial.println(F("Enabled"));
#else
Serial.println(F("Disabled"));
#endif
}

View File

@ -32,6 +32,9 @@
//AUTHENTICATION_FEATURE: protect pages by login password
#define AUTHENTICATION_FEATURE
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
#define WEB_UPDATE_FEATURE
#ifndef CONFIG_h
#define CONFIG_h

View File

@ -38,7 +38,7 @@ $SUCCESS_MSG$
</div>
</div>
</div>
<div class="panel">
<div class="panel" style="$WEB_UPDATE_VISIBILITY$">
<div class="panel-heading">Firmware Update</div>
<div class="panel-body">
<table><tr>

View File

@ -204,6 +204,7 @@ const char KEY_RETURN [] PROGMEM = "$RETURN$";
const char VALUE_CHANGE_PASSWORD [] PROGMEM = "Change Password";
const char MISSING_DATA [] PROGMEM = "Error: Missing data";
const char EEPROM_NOWRITE [] PROGMEM = "Error: Cannot write to EEPROM";
const char KEY_WEB_UPDATE [] PROGMEM = "$WEB_UPDATE_VISIBILITY$";
bool WEBINTERFACE_CLASS::isHostnameValid(const char * hostname)
{
@ -1183,7 +1184,12 @@ void handle_web_interface_configSys()
{
ProcessNoAlert(KeysList, ValuesList);
}
KeysList.add(FPSTR(KEY_WEB_UPDATE));
#ifdef WEB_UPDATE_FEATURE
ValuesList.add(FPSTR(VALUE_ITEM_VISIBLE));
#else
ValuesList.add(FPSTR(VALUE_ITEM_HIDDEN));
#endif
//Firmware and Free Mem, at the end to reflect situation
GetFreeMem(KeysList, ValuesList);
@ -2378,6 +2384,7 @@ void SPIFFSFileupload()
}
}
#ifdef WEB_UPDATE_FEATURE
void WebUpdateUpload()
{
HTTPUpload& upload = (web_interface->WebServer).upload();
@ -2404,7 +2411,6 @@ void WebUpdateUpload()
yield();
}
void handleUpdate()
{
web_interface->is_authenticated();
@ -2419,6 +2425,7 @@ void handleUpdate()
web_interface->restartmodule=true;
}
}
#endif
void handleFileList()
{
@ -2679,6 +2686,7 @@ void handle_login()
KeysList.clear();
ValuesList.clear();
}
void handle_restart()
{
if (SPIFFS.exists("/restart.tpl")) {
@ -2746,7 +2754,6 @@ void handle_web_command()
}
}
#ifdef SSDP_FEATURE
void handle_SSDP()
{
@ -2791,7 +2798,6 @@ void WEBINTERFACE_CLASS::urldecode( String & dst, const char *src)
}
}
//constructor
WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
{
@ -2805,7 +2811,9 @@ WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
WebServer.on("/PRINTER",HTTP_ANY, handle_web_interface_printer);
WebServer.on("/CMD",HTTP_ANY, handle_web_command);
WebServer.on("/RESTART",HTTP_GET, handle_restart);
#ifdef WEB_UPDATE_FEATURE
WebServer.on("/UPDATE",HTTP_ANY, handleUpdate,WebUpdateUpload);
#endif
WebServer.on("/FILES", HTTP_ANY, handleFileList,SPIFFSFileupload);
WebServer.on("/SDFILES", HTTP_ANY, handleSDFileList);
WebServer.on("/LOGIN", HTTP_ANY, handle_login);