mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add Ethernet
This commit is contained in:
@@ -20,6 +20,10 @@ void APSettingsService::reconfigureAP() {
|
||||
}
|
||||
|
||||
void APSettingsService::loop() {
|
||||
// if we have an ETH connection, quit
|
||||
if (ETH.linkUp()) {
|
||||
return;
|
||||
}
|
||||
unsigned long currentMillis = uuid::get_uptime();
|
||||
unsigned long manageElapsed = (uint32_t)(currentMillis - _lastManaged);
|
||||
if (manageElapsed >= MANAGE_NETWORK_DELAY) {
|
||||
@@ -42,13 +46,13 @@ void APSettingsService::manageAP() {
|
||||
}
|
||||
|
||||
void APSettingsService::startAP() {
|
||||
// Serial.println(F("Starting software access point"));
|
||||
Serial.println(F("Starting software access point"));
|
||||
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
|
||||
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str());
|
||||
if (!_dnsServer) {
|
||||
IPAddress apIp = WiFi.softAPIP();
|
||||
// Serial.print(F("Starting captive portal on "));
|
||||
// Serial.println(apIp);
|
||||
Serial.print(F("Starting captive portal on "));
|
||||
Serial.println(apIp);
|
||||
_dnsServer = new DNSServer;
|
||||
_dnsServer->start(DNS_PORT, "*", apIp);
|
||||
}
|
||||
@@ -56,12 +60,12 @@ void APSettingsService::startAP() {
|
||||
|
||||
void APSettingsService::stopAP() {
|
||||
if (_dnsServer) {
|
||||
// Serial.println(F("Stopping captive portal"));
|
||||
Serial.println(F("Stopping captive portal"));
|
||||
_dnsServer->stop();
|
||||
delete _dnsServer;
|
||||
_dnsServer = nullptr;
|
||||
}
|
||||
// Serial.println(F("Stopping software access point"));
|
||||
Serial.println(F("Stopping software access point"));
|
||||
WiFi.softAPdisconnect(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user