Add support for mDNS #161

This commit is contained in:
proddy
2021-10-18 13:02:22 +02:00
parent e17ce9c3b5
commit 45fc6daa4a
7 changed files with 40 additions and 20 deletions

View File

@@ -62,6 +62,7 @@ void NetworkSettingsService::manageSTA() {
}
WiFi.setHostname(_state.hostname.c_str()); // set hostname
// www.esp32.com/viewtopic.php?t=12055
read([&](NetworkSettings & networkSettings) {
if (networkSettings.bandwidth20) {
@@ -74,31 +75,17 @@ void NetworkSettingsService::manageSTA() {
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
}
});
WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); // attempt to connect to the network
}
}
// handles both WiFI and Ethernet
// handles if wifi stopped
void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) {
switch (event) {
case SYSTEM_EVENT_STA_DISCONNECTED:
WiFi.disconnect(true);
break;
case SYSTEM_EVENT_STA_STOP:
if (event == SYSTEM_EVENT_STA_STOP) {
if (_stopping) {
_lastConnectionAttempt = 0;
_stopping = false;
}
break;
case SYSTEM_EVENT_ETH_START:
if (_state.staticIPConfig) {
ETH.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2); // configure for static IP
}
break;
default:
break;
}
}