2021-01-15 05:21:33 +00:00
|
|
|
#include "mesh/http/WiFiAPClient.h"
|
2020-09-18 17:48:39 +00:00
|
|
|
#include "NodeDB.h"
|
2022-01-04 01:35:20 +00:00
|
|
|
#include "RTC.h"
|
2021-08-02 18:28:57 +00:00
|
|
|
#include "concurrency/Periodic.h"
|
2020-09-13 04:43:41 +00:00
|
|
|
#include "configuration.h"
|
|
|
|
#include "main.h"
|
2021-01-15 05:21:33 +00:00
|
|
|
#include "mesh/http/WebServer.h"
|
|
|
|
#include "mesh/wifi/WiFiServerAPI.h"
|
2022-01-02 07:10:37 +00:00
|
|
|
#include "mqtt/MQTT.h"
|
2020-09-27 07:55:41 +00:00
|
|
|
#include "target_specific.h"
|
2020-09-19 01:02:56 +00:00
|
|
|
#include <DNSServer.h>
|
2020-10-19 04:39:02 +00:00
|
|
|
#include <ESPmDNS.h>
|
2020-09-19 01:51:42 +00:00
|
|
|
#include <WiFi.h>
|
2021-12-29 03:24:10 +00:00
|
|
|
#include <WiFiUdp.h>
|
2020-09-18 17:48:39 +00:00
|
|
|
|
2022-04-14 02:23:35 +00:00
|
|
|
#ifndef DISABLE_NTP
|
|
|
|
#include <NTPClient.h>
|
|
|
|
#endif
|
|
|
|
|
2021-08-02 18:28:57 +00:00
|
|
|
using namespace concurrency;
|
|
|
|
|
2020-09-18 17:48:39 +00:00
|
|
|
static void WiFiEvent(WiFiEvent_t event);
|
2020-09-13 04:43:41 +00:00
|
|
|
|
2020-09-26 07:01:02 +00:00
|
|
|
// DNS Server for the Captive Portal
|
2020-09-18 22:33:03 +00:00
|
|
|
DNSServer dnsServer;
|
2020-09-26 07:01:02 +00:00
|
|
|
|
2021-12-29 03:24:10 +00:00
|
|
|
// NTP
|
|
|
|
WiFiUDP ntpUDP;
|
2022-04-14 02:23:35 +00:00
|
|
|
|
|
|
|
#ifndef DISABLE_NTP
|
2022-05-21 20:38:33 +00:00
|
|
|
NTPClient timeClient(ntpUDP, config.device.ntp_server);
|
2022-04-14 02:23:35 +00:00
|
|
|
#endif
|
2021-12-29 03:24:10 +00:00
|
|
|
|
2020-09-20 04:58:21 +00:00
|
|
|
uint8_t wifiDisconnectReason = 0;
|
|
|
|
|
2020-10-12 03:38:09 +00:00
|
|
|
// Stores our hostname
|
2020-10-19 04:39:02 +00:00
|
|
|
char ourHost[16];
|
2020-09-27 07:55:41 +00:00
|
|
|
|
2020-12-13 02:33:52 +00:00
|
|
|
bool forcedSoftAP = 0;
|
|
|
|
|
2020-12-13 06:37:07 +00:00
|
|
|
bool APStartupComplete = 0;
|
|
|
|
|
2021-08-02 18:28:57 +00:00
|
|
|
static bool needReconnect = true; // If we create our reconnector, run it once at the beginning
|
|
|
|
|
2021-08-03 00:42:44 +00:00
|
|
|
// FIXME, veto light sleep if we have a TCP server running
|
|
|
|
#if 0
|
|
|
|
class WifiSleepObserver : public Observer<uint32_t> {
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/// Return 0 if sleep is okay
|
|
|
|
virtual int onNotify(uint32_t newValue) {
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static WifiSleepObserver wifiSleepObserver;
|
|
|
|
//preflightSleepObserver.observe(&preflightSleep);
|
|
|
|
#endif
|
|
|
|
|
2021-08-02 18:28:57 +00:00
|
|
|
static int32_t reconnectWiFi()
|
|
|
|
{
|
2022-05-21 20:38:33 +00:00
|
|
|
const char *wifiName = config.wifi.ssid;
|
|
|
|
const char *wifiPsw = config.wifi.psk;
|
2021-12-29 03:24:10 +00:00
|
|
|
|
2022-05-07 10:31:21 +00:00
|
|
|
if (needReconnect && !WiFi.isConnected()) {
|
|
|
|
// if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) {
|
2021-08-02 18:28:57 +00:00
|
|
|
|
|
|
|
if (!*wifiPsw) // Treat empty password as no password
|
|
|
|
wifiPsw = NULL;
|
|
|
|
|
|
|
|
if (*wifiName) {
|
|
|
|
needReconnect = false;
|
|
|
|
|
2021-11-29 05:56:34 +00:00
|
|
|
DEBUG_MSG("... Reconnecting to WiFi access point\n");
|
2021-08-02 18:28:57 +00:00
|
|
|
WiFi.mode(WIFI_MODE_STA);
|
|
|
|
WiFi.begin(wifiName, wifiPsw);
|
2021-12-29 03:24:10 +00:00
|
|
|
|
|
|
|
// Starting timeClient;
|
2021-08-02 18:28:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-14 02:23:35 +00:00
|
|
|
#ifndef DISABLE_NTP
|
2022-01-04 01:35:20 +00:00
|
|
|
if (WiFi.isConnected()) {
|
2021-12-29 03:24:10 +00:00
|
|
|
DEBUG_MSG("Updating NTP time\n");
|
2022-01-04 01:35:20 +00:00
|
|
|
if (timeClient.update()) {
|
|
|
|
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
|
|
|
|
|
|
|
struct timeval tv;
|
|
|
|
tv.tv_sec = timeClient.getEpochTime();
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
|
|
|
perhapsSetRTC(RTCQualityNTP, &tv);
|
2021-12-29 03:24:10 +00:00
|
|
|
|
2022-01-04 01:35:20 +00:00
|
|
|
} else {
|
|
|
|
DEBUG_MSG("NTP Update failed\n");
|
|
|
|
}
|
2021-12-29 03:24:10 +00:00
|
|
|
}
|
2022-04-14 02:23:35 +00:00
|
|
|
#endif
|
2021-12-29 03:24:10 +00:00
|
|
|
|
2022-05-12 12:45:27 +00:00
|
|
|
return 43200 * 1000; // every 12 hours
|
2021-08-02 18:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Periodic *wifiReconnect;
|
|
|
|
|
2020-12-13 05:43:01 +00:00
|
|
|
bool isSoftAPForced()
|
|
|
|
{
|
2020-12-13 03:09:58 +00:00
|
|
|
return forcedSoftAP;
|
|
|
|
}
|
|
|
|
|
2020-09-19 01:51:42 +00:00
|
|
|
bool isWifiAvailable()
|
2020-09-17 03:15:00 +00:00
|
|
|
{
|
2020-12-13 02:33:52 +00:00
|
|
|
// If wifi status is connected, return true regardless of the radio configuration.
|
2020-12-13 03:09:58 +00:00
|
|
|
if (isSoftAPForced()) {
|
2021-05-24 01:42:25 +00:00
|
|
|
return true;
|
2020-12-13 02:33:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 20:38:33 +00:00
|
|
|
const char *wifiName = config.wifi.ssid;
|
2020-09-17 03:15:00 +00:00
|
|
|
|
2021-05-24 01:21:52 +00:00
|
|
|
if (*wifiName) {
|
2021-05-24 01:42:25 +00:00
|
|
|
return true;
|
2020-09-17 03:15:00 +00:00
|
|
|
} else {
|
2021-05-24 01:42:25 +00:00
|
|
|
return false;
|
2020-09-17 03:15:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable WiFi
|
2020-09-15 03:27:49 +00:00
|
|
|
void deinitWifi()
|
|
|
|
{
|
2020-09-18 17:48:39 +00:00
|
|
|
/*
|
2020-09-19 19:50:43 +00:00
|
|
|
Note from Jm (jm@casler.org - Sept 16, 2020):
|
2020-09-18 17:48:39 +00:00
|
|
|
|
2020-09-17 05:31:07 +00:00
|
|
|
A bug in the ESP32 SDK was introduced in Oct 2019 that keeps the WiFi radio from
|
|
|
|
turning back on after it's shut off. See:
|
|
|
|
https://github.com/espressif/arduino-esp32/issues/3522
|
|
|
|
|
|
|
|
Until then, WiFi should only be allowed when there's no power
|
|
|
|
saving on the 2.4g transceiver.
|
2020-09-18 17:48:39 +00:00
|
|
|
*/
|
2020-09-17 05:31:07 +00:00
|
|
|
|
2021-12-24 02:18:07 +00:00
|
|
|
DEBUG_MSG("WiFi deinit\n");
|
|
|
|
|
2020-11-27 22:49:44 +00:00
|
|
|
if (isWifiAvailable()) {
|
|
|
|
WiFi.mode(WIFI_MODE_NULL);
|
|
|
|
DEBUG_MSG("WiFi Turned Off\n");
|
|
|
|
// WiFi.printDiag(Serial);
|
|
|
|
}
|
2020-09-15 03:27:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 02:59:56 +00:00
|
|
|
static void onNetworkConnected()
|
2021-08-18 00:04:09 +00:00
|
|
|
{
|
|
|
|
if (!APStartupComplete) {
|
|
|
|
// Start web server
|
|
|
|
DEBUG_MSG("... Starting network services\n");
|
|
|
|
|
|
|
|
// start mdns
|
|
|
|
if (!MDNS.begin("Meshtastic")) {
|
|
|
|
DEBUG_MSG("Error setting up MDNS responder!\n");
|
|
|
|
} else {
|
|
|
|
DEBUG_MSG("mDNS responder started\n");
|
|
|
|
DEBUG_MSG("mDNS Host: Meshtastic.local\n");
|
|
|
|
MDNS.addService("http", "tcp", 80);
|
|
|
|
MDNS.addService("https", "tcp", 443);
|
|
|
|
}
|
|
|
|
|
2022-04-14 02:23:35 +00:00
|
|
|
#ifndef DISABLE_NTP
|
2021-12-29 03:24:10 +00:00
|
|
|
DEBUG_MSG("Starting NTP time client\n");
|
|
|
|
timeClient.begin();
|
2022-04-14 02:23:35 +00:00
|
|
|
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
|
|
|
#endif
|
2021-12-29 03:24:10 +00:00
|
|
|
|
2021-08-18 00:04:09 +00:00
|
|
|
initWebServer();
|
|
|
|
initApiServer();
|
|
|
|
|
|
|
|
APStartupComplete = true;
|
2022-01-02 07:10:37 +00:00
|
|
|
}
|
2021-08-18 02:59:56 +00:00
|
|
|
|
|
|
|
// FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected'
|
2022-01-02 07:10:37 +00:00
|
|
|
if (mqtt)
|
2021-08-18 02:59:56 +00:00
|
|
|
mqtt->reconnect();
|
2021-08-18 00:04:09 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 03:15:00 +00:00
|
|
|
// Startup WiFi
|
2021-08-17 23:58:21 +00:00
|
|
|
bool initWifi(bool forceSoftAP)
|
2020-09-13 04:43:41 +00:00
|
|
|
{
|
2020-12-13 02:33:52 +00:00
|
|
|
forcedSoftAP = forceSoftAP;
|
|
|
|
|
2022-05-21 20:38:33 +00:00
|
|
|
if ((config.wifi.ssid[0]) || forceSoftAP) {
|
|
|
|
// if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) {
|
|
|
|
const char *wifiName = config.wifi.ssid;
|
|
|
|
const char *wifiPsw = config.wifi.psk;
|
2020-09-18 22:33:03 +00:00
|
|
|
|
2022-01-02 07:10:37 +00:00
|
|
|
if (forceSoftAP) {
|
|
|
|
DEBUG_MSG("WiFi ... Forced AP Mode\n");
|
2022-05-21 20:38:33 +00:00
|
|
|
} else if (config.wifi.ap_mode) {
|
2022-01-02 07:10:37 +00:00
|
|
|
DEBUG_MSG("WiFi ... AP Mode\n");
|
|
|
|
} else {
|
|
|
|
DEBUG_MSG("WiFi ... Client Mode\n");
|
|
|
|
}
|
|
|
|
|
2021-08-17 23:58:21 +00:00
|
|
|
createSSLCert();
|
|
|
|
|
2021-05-24 01:21:52 +00:00
|
|
|
if (!*wifiPsw) // Treat empty password as no password
|
|
|
|
wifiPsw = NULL;
|
|
|
|
|
|
|
|
if (*wifiName || forceSoftAP) {
|
2022-05-21 20:38:33 +00:00
|
|
|
if (config.wifi.ap_mode || forceSoftAP) {
|
2020-12-13 02:33:52 +00:00
|
|
|
|
|
|
|
IPAddress apIP(192, 168, 42, 1);
|
|
|
|
WiFi.onEvent(WiFiEvent);
|
2021-12-24 02:18:07 +00:00
|
|
|
WiFi.mode(WIFI_AP);
|
2020-12-13 02:33:52 +00:00
|
|
|
|
2021-12-24 02:18:07 +00:00
|
|
|
if (forcedSoftAP) {
|
|
|
|
const char *softAPssid = "meshtasticAdmin";
|
|
|
|
const char *softAPpasswd = "12345678";
|
2022-03-14 19:31:13 +00:00
|
|
|
int ok = WiFi.softAP(softAPssid, softAPpasswd);
|
|
|
|
DEBUG_MSG("Starting (Forced) WIFI AP: ssid=%s, ok=%d\n", softAPssid, ok);
|
2020-12-13 02:33:52 +00:00
|
|
|
|
2021-12-24 02:18:07 +00:00
|
|
|
} else {
|
2022-05-22 03:10:36 +00:00
|
|
|
|
|
|
|
// If AP is configured to be hidden hidden
|
|
|
|
if (config.payloadVariant.wifi.ap_hidden) {
|
|
|
|
|
|
|
|
// The configurations on softAP are from the espresif library
|
|
|
|
int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4);
|
|
|
|
DEBUG_MSG("Starting hiddem WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
|
|
|
} else {
|
|
|
|
int ok = WiFi.softAP(wifiName, wifiPsw);
|
|
|
|
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
|
|
|
}
|
2022-03-14 19:40:57 +00:00
|
|
|
int ok = WiFi.softAP(wifiName, wifiPsw);
|
2022-03-14 19:31:13 +00:00
|
|
|
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
2021-12-24 02:18:07 +00:00
|
|
|
}
|
2020-09-18 22:33:03 +00:00
|
|
|
|
|
|
|
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
2021-12-24 02:18:07 +00:00
|
|
|
DEBUG_MSG("MY IP AP ADDRESS: %s\n", WiFi.softAPIP().toString().c_str());
|
2021-12-24 21:08:30 +00:00
|
|
|
|
|
|
|
// This is needed to improve performance.
|
2021-12-24 02:18:07 +00:00
|
|
|
esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving
|
2020-09-18 22:33:03 +00:00
|
|
|
|
|
|
|
dnsServer.start(53, "*", apIP);
|
|
|
|
|
2020-09-13 04:43:41 +00:00
|
|
|
} else {
|
2020-09-27 07:55:41 +00:00
|
|
|
uint8_t dmac[6];
|
|
|
|
getMacAddr(dmac);
|
|
|
|
sprintf(ourHost, "Meshtastic-%02x%02x", dmac[4], dmac[5]);
|
|
|
|
|
2020-09-13 04:43:41 +00:00
|
|
|
WiFi.mode(WIFI_MODE_STA);
|
2020-09-27 07:55:41 +00:00
|
|
|
WiFi.setHostname(ourHost);
|
2020-09-13 04:43:41 +00:00
|
|
|
WiFi.onEvent(WiFiEvent);
|
2021-12-24 21:08:30 +00:00
|
|
|
|
|
|
|
// This is needed to improve performance.
|
2021-12-24 02:18:07 +00:00
|
|
|
esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving
|
2020-09-13 04:43:41 +00:00
|
|
|
|
2020-09-27 07:55:41 +00:00
|
|
|
WiFi.onEvent(
|
2020-09-20 04:58:21 +00:00
|
|
|
[](WiFiEvent_t event, WiFiEventInfo_t info) {
|
2020-09-23 04:01:31 +00:00
|
|
|
Serial.print("\nWiFi lost connection. Reason: ");
|
2020-09-20 04:58:21 +00:00
|
|
|
Serial.println(info.disconnected.reason);
|
2020-09-26 07:01:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
If we are disconnected from the AP for some reason,
|
|
|
|
save the error code.
|
|
|
|
|
|
|
|
For a reference to the codes:
|
|
|
|
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code
|
|
|
|
*/
|
|
|
|
wifiDisconnectReason = info.disconnected.reason;
|
2020-09-20 04:58:21 +00:00
|
|
|
},
|
|
|
|
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
|
|
|
|
|
2021-08-02 18:28:57 +00:00
|
|
|
DEBUG_MSG("JOINING WIFI soon: ssid=%s\n", wifiName);
|
|
|
|
wifiReconnect = new Periodic("WifiConnect", reconnectWiFi);
|
2020-09-13 04:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-17 23:58:21 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2020-09-13 04:43:41 +00:00
|
|
|
DEBUG_MSG("Not using WIFI\n");
|
2021-08-17 23:58:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-09-13 04:43:41 +00:00
|
|
|
}
|
|
|
|
|
2020-09-26 07:01:02 +00:00
|
|
|
// Called by the Espressif SDK to
|
2020-09-18 17:48:39 +00:00
|
|
|
static void WiFiEvent(WiFiEvent_t event)
|
2020-09-13 04:43:41 +00:00
|
|
|
{
|
|
|
|
DEBUG_MSG("************ [WiFi-event] event: %d ************\n", event);
|
|
|
|
|
|
|
|
switch (event) {
|
2020-09-18 17:48:39 +00:00
|
|
|
case SYSTEM_EVENT_WIFI_READY:
|
|
|
|
DEBUG_MSG("WiFi interface ready\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_SCAN_DONE:
|
|
|
|
DEBUG_MSG("Completed scan for access points\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_START:
|
2021-08-03 00:42:44 +00:00
|
|
|
DEBUG_MSG("WiFi station started\n");
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_STOP:
|
2021-08-03 00:42:44 +00:00
|
|
|
DEBUG_MSG("WiFi station stopped\n");
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_CONNECTED:
|
|
|
|
DEBUG_MSG("Connected to access point\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
|
|
|
DEBUG_MSG("Disconnected from WiFi access point\n");
|
2020-09-19 23:38:59 +00:00
|
|
|
// Event 5
|
2020-09-18 17:48:39 +00:00
|
|
|
|
2021-08-02 18:28:57 +00:00
|
|
|
needReconnect = true;
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
|
|
|
|
DEBUG_MSG("Authentication mode of access point has changed\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_GOT_IP:
|
2021-12-24 02:18:07 +00:00
|
|
|
DEBUG_MSG("Obtained IP address: ");
|
2020-09-18 17:48:39 +00:00
|
|
|
Serial.println(WiFi.localIP());
|
2021-08-18 02:59:56 +00:00
|
|
|
onNetworkConnected();
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_LOST_IP:
|
|
|
|
DEBUG_MSG("Lost IP address and IP address is reset to 0\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
|
|
|
DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
|
|
|
|
DEBUG_MSG("WiFi Protected Setup (WPS): failed in enrollee mode\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
|
|
|
|
DEBUG_MSG("WiFi Protected Setup (WPS): timeout in enrollee mode\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_STA_WPS_ER_PIN:
|
|
|
|
DEBUG_MSG("WiFi Protected Setup (WPS): pin code in enrollee mode\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_START:
|
|
|
|
DEBUG_MSG("WiFi access point started\n");
|
2021-12-24 21:08:30 +00:00
|
|
|
|
2021-08-18 02:59:56 +00:00
|
|
|
onNetworkConnected();
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_STOP:
|
|
|
|
DEBUG_MSG("WiFi access point stopped\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_STACONNECTED:
|
|
|
|
DEBUG_MSG("Client connected\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
|
|
|
DEBUG_MSG("Client disconnected\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_STAIPASSIGNED:
|
|
|
|
DEBUG_MSG("Assigned IP address to client\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_AP_PROBEREQRECVED:
|
|
|
|
DEBUG_MSG("Received probe request\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_GOT_IP6:
|
|
|
|
DEBUG_MSG("IPv6 is preferred\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_ETH_START:
|
|
|
|
DEBUG_MSG("Ethernet started\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_ETH_STOP:
|
|
|
|
DEBUG_MSG("Ethernet stopped\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_ETH_CONNECTED:
|
|
|
|
DEBUG_MSG("Ethernet connected\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
|
|
|
DEBUG_MSG("Ethernet disconnected\n");
|
|
|
|
break;
|
|
|
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
2021-12-24 02:18:07 +00:00
|
|
|
DEBUG_MSG("Obtained IP address (SYSTEM_EVENT_ETH_GOT_IP)\n");
|
2020-09-18 17:48:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2020-09-13 04:43:41 +00:00
|
|
|
}
|
2020-09-18 22:33:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 01:51:42 +00:00
|
|
|
void handleDNSResponse()
|
|
|
|
{
|
2022-05-21 20:38:33 +00:00
|
|
|
if (config.wifi.ap_mode || isSoftAPForced()) {
|
2020-09-18 22:33:03 +00:00
|
|
|
dnsServer.processNextRequest();
|
2020-09-13 04:43:41 +00:00
|
|
|
}
|
2020-09-19 23:38:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-26 07:01:02 +00:00
|
|
|
uint8_t getWifiDisconnectReason()
|
2020-09-20 04:58:21 +00:00
|
|
|
{
|
|
|
|
return wifiDisconnectReason;
|
2022-03-14 19:31:13 +00:00
|
|
|
}
|