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