mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 21:56:35 +00:00
Reorder SoftAP setup
This commit is contained in:
parent
220b0f39a0
commit
bde590394d
@ -195,7 +195,7 @@ void httpHandleReboot()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void webHandleScreenshot()
|
void webHandleScreenshot()
|
||||||
{ // http://plate01/about
|
{ // http://plate01/screenshot
|
||||||
if(!httpIsAuthenticated(F("/screenshot"))) return;
|
if(!httpIsAuthenticated(F("/screenshot"))) return;
|
||||||
|
|
||||||
if(webServer.hasArg(F("q"))) {
|
if(webServer.hasArg(F("q"))) {
|
||||||
@ -222,6 +222,7 @@ void webHandleScreenshot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void webHandleAbout()
|
void webHandleAbout()
|
||||||
{ // http://plate01/about
|
{ // http://plate01/about
|
||||||
if(!httpIsAuthenticated(F("/about"))) return;
|
if(!httpIsAuthenticated(F("/about"))) return;
|
||||||
@ -261,6 +262,7 @@ void webHandleAbout()
|
|||||||
webServer.sendContent(httpMessage); // len
|
webServer.sendContent(httpMessage); // len
|
||||||
webServer.sendContent_P(HTTP_END); // 20
|
webServer.sendContent_P(HTTP_END); // 20
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void webHandleInfo()
|
void webHandleInfo()
|
||||||
{ // http://plate01/
|
{ // http://plate01/
|
||||||
@ -336,8 +338,8 @@ void webHandleInfo()
|
|||||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||||
|
|
||||||
webSendPage(nodename, httpMessage.length(), false);
|
webSendPage(nodename, httpMessage.length(), false);
|
||||||
webServer.sendContent(httpMessage); // len
|
webServer.sendContent(httpMessage);
|
||||||
webServer.sendContent_P(HTTP_END); // 20
|
webServer.sendContent_P(HTTP_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getContentType(String filename)
|
String getContentType(String filename)
|
||||||
@ -370,7 +372,7 @@ String getContentType(String filename)
|
|||||||
return F("text/plain");
|
return F("text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
String urldecode(String str)
|
/* String urldecode(String str)
|
||||||
{
|
{
|
||||||
String encodedString = "";
|
String encodedString = "";
|
||||||
char c;
|
char c;
|
||||||
@ -394,13 +396,14 @@ String urldecode(String str)
|
|||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
return encodedString;
|
return encodedString;
|
||||||
}
|
} */
|
||||||
|
|
||||||
bool handleFileRead(String path)
|
bool handleFileRead(String path)
|
||||||
{
|
{
|
||||||
if(!httpIsAuthenticated(F("fileread"))) return false;
|
if(!httpIsAuthenticated(F("fileread"))) return false;
|
||||||
|
|
||||||
path = urldecode(path).substring(0, 31);
|
// path = urldecode(path).substring(0, 31);
|
||||||
|
path = webServer.urlDecode(path);
|
||||||
if(!httpIsAuthenticated(path)) return false;
|
if(!httpIsAuthenticated(path)) return false;
|
||||||
|
|
||||||
if(path.endsWith("/")) {
|
if(path.endsWith("/")) {
|
||||||
@ -988,6 +991,13 @@ void httpHandleResetConfig()
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void httpSetup(const JsonObject & settings)
|
void httpSetup(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
if(WiFi.getMode() == WIFI_AP) {
|
||||||
|
debugPrintln(F("HTTP: Wifi access point"));
|
||||||
|
webServer.on(F("/"), webHandleWifiConfig);
|
||||||
|
webServer.on(F("/config"), webHandleConfig);
|
||||||
|
webServer.onNotFound(httpHandleNotFound);
|
||||||
|
} else {
|
||||||
|
|
||||||
webServer.on(F("/page/"), []() {
|
webServer.on(F("/page/"), []() {
|
||||||
String pageid = webServer.arg(F("page"));
|
String pageid = webServer.arg(F("page"));
|
||||||
webServer.send(200, PSTR("text/plain"), "Page: '" + pageid + "'");
|
webServer.send(200, PSTR("text/plain"), "Page: '" + pageid + "'");
|
||||||
@ -1037,22 +1047,23 @@ void httpSetup(const JsonObject & settings)
|
|||||||
webServer.on(F("/reboot"), httpHandleReboot);
|
webServer.on(F("/reboot"), httpHandleReboot);
|
||||||
webServer.onNotFound(httpHandleNotFound);
|
webServer.onNotFound(httpHandleNotFound);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void httpReconnect()
|
void httpReconnect()
|
||||||
{
|
{
|
||||||
if(!httpEnable) return;
|
if(!httpEnable) return;
|
||||||
|
|
||||||
if(WiFi.getMode() == WIFI_AP) {
|
|
||||||
webServer.on(F("/"), webHandleWifiConfig);
|
|
||||||
webServer.on(F("/config"), webHandleConfig);
|
|
||||||
webServer.onNotFound(webHandleWifiConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
webServer.stop();
|
webServer.stop();
|
||||||
webServerStarted = false;
|
webServerStarted = false;
|
||||||
|
|
||||||
|
if(WiFi.getMode() == WIFI_AP) {
|
||||||
|
webServer.on(F("/"), webHandleWifiConfig);
|
||||||
|
webServer.on(F("/config"), webHandleConfig);
|
||||||
|
webServer.onNotFound(httpHandleNotFound);
|
||||||
|
} else {
|
||||||
if(WiFi.status() != WL_CONNECTED) return;
|
if(WiFi.status() != WL_CONNECTED) return;
|
||||||
|
}
|
||||||
|
|
||||||
webServer.begin();
|
webServer.begin();
|
||||||
webServerStarted = true;
|
webServerStarted = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user