Merge pull request #535 from iranl/fix-ap-not-opening
WiFI fixes (AP not opening, WiFi reconfigure not working)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#define NUKI_HUB_VERSION "9.02"
|
||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||
#define NUKI_HUB_DATE "2024-11-18"
|
||||
#define NUKI_HUB_DATE "2024-11-22"
|
||||
|
||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||
|
||||
@@ -4041,10 +4041,11 @@ esp_err_t WebCfgServer::buildConfigureWifiHtml(PsychicRequest *request)
|
||||
PsychicStreamResponse response(request, "text/plain");
|
||||
response.beginSend();
|
||||
buildHtmlHeader(&response);
|
||||
response.print("<form method=\"get\" action=\"wifimanager\">");
|
||||
response.print("<h3>Wi-Fi</h3>");
|
||||
response.print("Click confirm to remove saved WiFi settings and restart ESP into Wi-Fi configuration mode. After restart, connect to ESP access point to reconfigure Wi-Fi.<br><br>");
|
||||
String wifiMgrUrl = "/wifimanager?CONFIRMTOKEN=" + _confirmCode;
|
||||
buildNavigationButton(&response, "Confirm", wifiMgrUrl.c_str());
|
||||
response.print("Click confirm to remove saved WiFi settings and restart ESP into Wi-Fi configuration mode. After restart, connect to ESP access point to reconfigure Wi-Fi.<br><br><br>");
|
||||
response.print("<input type=\"hidden\" name=\"CONFIRMTOKEN\" value=\"" + _confirmCode + "\" /><input type=\"submit\" value=\"Reboot\" /></form>");
|
||||
response.print("</form>");
|
||||
response.print("</body></html>");
|
||||
return response.endSend();
|
||||
}
|
||||
@@ -4896,18 +4897,6 @@ void WebCfgServer::printDropDown(PsychicStreamResponse *response, const char *to
|
||||
response->print("</td></tr>");
|
||||
}
|
||||
|
||||
void WebCfgServer::buildNavigationButton(PsychicStreamResponse *response, const char *caption, const char *targetPath, const char* labelText)
|
||||
{
|
||||
response->print("<form method=\"get\" action=\"");
|
||||
response->print(targetPath);
|
||||
response->print("\">");
|
||||
response->print("<button type=\"submit\">");
|
||||
response->print(caption);
|
||||
response->print("</button> ");
|
||||
response->print(labelText);
|
||||
response->print("</form>");
|
||||
}
|
||||
|
||||
void WebCfgServer::buildNavigationMenuEntry(PsychicStreamResponse *response, const char *title, const char *targetPath, const char* warningMessage)
|
||||
{
|
||||
response->print("<a href=\"");
|
||||
|
||||
@@ -72,7 +72,6 @@ private:
|
||||
esp_err_t processFactoryReset(PsychicRequest *request);
|
||||
void printTextarea(PsychicStreamResponse *response, const char *token, const char *description, const char *value, const size_t& maxLength, const bool& enabled = true, const bool& showLengthRestriction = false);
|
||||
void printDropDown(PsychicStreamResponse *response, const char *token, const char *description, const String preselectedValue, std::vector<std::pair<String, String>> options, const String className);
|
||||
void buildNavigationButton(PsychicStreamResponse *response, const char* caption, const char* targetPath, const char* labelText = "");
|
||||
void buildNavigationMenuEntry(PsychicStreamResponse *response, const char *title, const char *targetPath, const char* warningMessage = "");
|
||||
|
||||
const std::vector<std::pair<String, String>> getNetworkDetectionOptions() const;
|
||||
|
||||
@@ -63,16 +63,7 @@ void WifiDevice::initialize()
|
||||
String(F(" and channel: ")) + String(WiFi.channel(i)));
|
||||
}
|
||||
|
||||
if ((_connectOnScanDone && _foundNetworks > 0) || _preferences->getBool(preference_find_best_rssi, false))
|
||||
{
|
||||
connect();
|
||||
}
|
||||
else if (_connectOnScanDone)
|
||||
{
|
||||
Log->println("No networks found, restarting scan");
|
||||
scan(false, true);
|
||||
}
|
||||
else if (_openAP)
|
||||
if (_openAP)
|
||||
{
|
||||
openAP();
|
||||
}
|
||||
@@ -127,6 +118,15 @@ void WifiDevice::initialize()
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ((_connectOnScanDone && _foundNetworks > 0) || _preferences->getBool(preference_find_best_rssi, false))
|
||||
{
|
||||
connect();
|
||||
}
|
||||
else if (_connectOnScanDone)
|
||||
{
|
||||
Log->println("No networks found, restarting scan");
|
||||
scan(false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -190,14 +190,16 @@ void WifiDevice::openAP()
|
||||
{
|
||||
if(_startAP)
|
||||
{
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
WiFi.softAPsetHostname(_hostname.c_str());
|
||||
WiFi.softAP("NukiHub", "NukiHubESP32");
|
||||
_startAP = false;
|
||||
WiFi.mode(WIFI_AP);
|
||||
delay(500);
|
||||
WiFi.softAPsetHostname(_hostname.c_str());
|
||||
delay(500);
|
||||
WiFi.softAP("NukiHub", "NukiHubESP32");
|
||||
|
||||
if(MDNS.begin(_hostname.c_str())){
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
}
|
||||
//if(MDNS.begin(_hostname.c_str())){
|
||||
// MDNS.addService("http", "tcp", 80);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user