mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-04 21:15:52 +00:00
updates
This commit is contained in:
@@ -35,12 +35,12 @@
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
#define NETWORK_RECONNECTION_DELAY_SHORT 3000 // 3 seconds
|
||||
#define NETWORK_RECONNECTION_DELAY_LONG 60000 // 60 seconds
|
||||
#define NETWORK_RECONNECTION_DELAY_SHORT 5000 // 5 seconds
|
||||
#define NETWORK_RECONNECTION_DELAY_LONG 60000 // 1 minute
|
||||
|
||||
#define MAX_NETWORK_RECONNECTION_ATTEMPTS 3 // maximum number of network reconnection attempts
|
||||
#define MAX_NETWORK_RECONNECTION_ATTEMPTS 4 // maximum number of network reconnection attempts before going to AP fallback
|
||||
|
||||
#define DNS_PORT 53
|
||||
#define DNS_PORT 53 // dns server port for captive portal
|
||||
|
||||
// copied from Tasmota
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
@@ -79,9 +79,9 @@ namespace emsesp {
|
||||
// multiple ETH instances) -> ETHERNET. Anything else stays as NONE.
|
||||
enum class NetIface : uint8_t {
|
||||
NONE = 0,
|
||||
WIFI,
|
||||
ETHERNET,
|
||||
AP,
|
||||
WIFI, // 1
|
||||
ETHERNET, // 2
|
||||
AP, // 3
|
||||
};
|
||||
|
||||
class Network {
|
||||
@@ -118,7 +118,7 @@ class Network {
|
||||
}
|
||||
|
||||
uint16_t getNetworkReconnects() {
|
||||
return connectcount_;
|
||||
return reconnect_count_;
|
||||
}
|
||||
|
||||
std::string getLocalIP() const;
|
||||
@@ -145,10 +145,25 @@ class Network {
|
||||
return NetIface::NONE;
|
||||
}
|
||||
|
||||
static const char * network_iface_to_string(NetIface iface) {
|
||||
switch (iface) {
|
||||
case NetIface::WIFI:
|
||||
return "WiFi";
|
||||
case NetIface::ETHERNET:
|
||||
return "Ethernet";
|
||||
case NetIface::AP:
|
||||
return "AP";
|
||||
case NetIface::NONE:
|
||||
default:
|
||||
return "None";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
private:
|
||||
static uuid::log::Logger logger_;
|
||||
|
||||
bool findNetworks();
|
||||
void findNetworks();
|
||||
void checkConnection();
|
||||
void startmDNS() const;
|
||||
bool formatBSSID(const String & bssid, uint8_t (&mac)[6]);
|
||||
@@ -165,7 +180,7 @@ class Network {
|
||||
#endif
|
||||
|
||||
unsigned long lastConnectionAttempt_ = 0;
|
||||
uint16_t connectcount_ = 0; // number of network reconnects
|
||||
uint16_t reconnect_count_ = 0; // number of network reconnects
|
||||
uint32_t network_ip_ = 0;
|
||||
NetIface network_iface_ = NetIface::NONE;
|
||||
bool has_ipv6_ = false;
|
||||
@@ -173,7 +188,11 @@ class Network {
|
||||
bool eth_started_ = false; // true after ETH.begin() has succeeded once; prevents repeated re-init while DHCP is still running
|
||||
volatile uint8_t last_disconnect_reason_ = 0;
|
||||
uint16_t connect_retry_ = 0; // number of network re-connection attempts
|
||||
volatile bool wifi_connect_pending_ = false;
|
||||
|
||||
volatile bool wifi_connect_pending_ = false;
|
||||
|
||||
bool wifi_events_registered_ = false; // ensure WiFi.onEvent() handlers are registered only once across begin()/reconnect() cycles
|
||||
bool wifi_ever_connected_ = false; // set true once we've successfully obtained an IP; used to silence the harmless first-attempt disconnect emitted by arduino-esp32's built-in retry-once behaviour
|
||||
|
||||
// Network and AP settings
|
||||
bool enableMDNS_;
|
||||
|
||||
Reference in New Issue
Block a user