add Ethernet

This commit is contained in:
proddy
2021-01-18 19:38:22 +01:00
parent b81435e713
commit 44045ae658
60 changed files with 905 additions and 973 deletions

View File

@@ -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);
}