some big change using state machine
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
WIFIMANAGER Network::WifiManager;
|
||||
AsyncWebServer Network::webServer(80);
|
||||
|
||||
Network::Network(std::string hostname, std::string apSsid) : hostname(hostname), apSsid(apSsid) {
|
||||
Network::Network(std::string_view hostname, std::string_view apSsid) : hostname(hostname), apSsid(apSsid) {
|
||||
setHostname(hostname);
|
||||
WifiManager.startBackgroundTask(apSsid.c_str(), "");
|
||||
WifiManager.startBackgroundTask(apSsid.data(), "");
|
||||
WifiManager.fallbackToSoftAp(true);
|
||||
WifiManager.attachWebServer(&webServer);
|
||||
WifiManager.attachUI();
|
||||
webServer.on("/", HTTP_GET, [this](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/html", this->defaultHomepage.c_str());
|
||||
request->send(200, "text/html", this->defaultHomepage.data());
|
||||
});
|
||||
webServer.begin();
|
||||
}
|
||||
@@ -25,14 +25,14 @@ std::string Network::getHostname() const {
|
||||
return WiFi.getHostname();
|
||||
}
|
||||
|
||||
bool Network::setHostname(const std::string &hostname) {
|
||||
return WiFi.setHostname(hostname.c_str());
|
||||
bool Network::setHostname(const std::string_view &hostname) {
|
||||
return WiFi.setHostname(hostname.data());
|
||||
}
|
||||
|
||||
void Network::registerMDNS() {
|
||||
if (!MDNS.begin(hostname.c_str())) {
|
||||
if (!MDNS.begin(hostname.data())) {
|
||||
Serial.println("Error setting up MDNS responder!");
|
||||
} else {
|
||||
Serial.printf("mDNS responder started with hostname: %s\n", hostname.c_str());
|
||||
Serial.printf("mDNS responder started with hostname: %s\n", hostname.data());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user