mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-13 19:36:26 +03:00
Compare commits
7 Commits
8785bde7b6
...
0867e166e1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0867e166e1 | ||
|
|
ba7d9b33d8 | ||
|
|
04934c6bca | ||
|
|
0b9eec0849 | ||
|
|
31166794dd | ||
|
|
d85c1dc8e8 | ||
|
|
ecb8b5df0c |
@@ -16,3 +16,4 @@ For more details go to [emsesp.org](https://emsesp.org/).
|
|||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
- various memory optimizations [#3083](https://github.com/emsesp/EMS-ESP32/issues/3083)
|
- various memory optimizations [#3083](https://github.com/emsesp/EMS-ESP32/issues/3083)
|
||||||
|
- network fallback to AP only after start [#3090](https://github.com/emsesp/EMS-ESP32/issues/3090)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ lib_deps =
|
|||||||
bblanchon/ArduinoJson @ 7.4.3
|
bblanchon/ArduinoJson @ 7.4.3
|
||||||
ESP32Async/AsyncTCP @ 3.4.10
|
ESP32Async/AsyncTCP @ 3.4.10
|
||||||
ESP32Async/ESPAsyncWebServer @ 3.11.0
|
ESP32Async/ESPAsyncWebServer @ 3.11.0
|
||||||
https://github.com/mobizt/ReadyMail.git @ 0.4.0
|
https://github.com/mobizt/ReadyMail.git @ 0.4.2
|
||||||
https://github.com/mobizt/ESP_SSLClient.git @ 3.1.3
|
https://github.com/mobizt/ESP_SSLClient.git @ 3.1.3
|
||||||
; https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
|
; https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
// Gateways - 0x48
|
// Gateways - 0x48
|
||||||
{17, DeviceType::GATEWAY, "MX400", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x48, 0x4B, or 0x50 as wireless base
|
{17, DeviceType::GATEWAY, "MX400", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x48, 0x4B, or 0x50 as wireless base
|
||||||
{189, DeviceType::GATEWAY, "KM200, MB LAN 2", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x48
|
{189, DeviceType::GATEWAY, "KM200, MB LAN 2", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x48
|
||||||
{222, DeviceType::GATEWAY, "KM300,", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x4A
|
{222, DeviceType::GATEWAY, "KM300", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x4A
|
||||||
{252, DeviceType::GATEWAY, "K30RF, MX300", DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
{252, DeviceType::GATEWAY, "K30RF, MX300", DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
// Generic - 0x40 or other with no product-id and no version
|
// Generic - 0x40 or other with no product-id and no version
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ void Network::begin() {
|
|||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.setAutoReconnect(false);
|
WiFi.setAutoReconnect(false);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.disconnect(true); // wipe old settings in NVS
|
WiFi.disconnect(true, true); // wipe old settings in NVS
|
||||||
|
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||||
WiFi.setHostname(hostname_.c_str()); // updates shared default_hostname buffer
|
WiFi.setHostname(hostname_.c_str()); // updates shared default_hostname buffer
|
||||||
WiFi.enableSTA(true); // creates the STA netif
|
WiFi.enableSTA(true); // creates the STA netif
|
||||||
WiFi.STA.setHostname(hostname_.c_str()); // pushes to esp_netif_set_hostname
|
WiFi.STA.setHostname(hostname_.c_str()); // pushes to esp_netif_set_hostname
|
||||||
@@ -235,7 +236,6 @@ void Network::reconnect() {
|
|||||||
last_disconnect_reason_ = 0;
|
last_disconnect_reason_ = 0;
|
||||||
connect_retry_ = 0;
|
connect_retry_ = 0;
|
||||||
reconnect_count_ = 0;
|
reconnect_count_ = 0;
|
||||||
phase_ = NetPhase::ETHERNET; // begin() will refine this once settings are reloaded
|
|
||||||
|
|
||||||
// reload the network settings and apply them
|
// reload the network settings and apply them
|
||||||
begin();
|
begin();
|
||||||
@@ -304,23 +304,15 @@ void Network::checkConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!still_up) {
|
if (!still_up) {
|
||||||
if (network_iface_ == NetIface::WIFI) {
|
|
||||||
uint8_t reason = last_disconnect_reason_;
|
|
||||||
if (reason == 0) {
|
|
||||||
reason = WIFI_REASON_UNSPECIFIED; // event hasn't fired yet (or was cleared); avoid logging "0"
|
|
||||||
}
|
|
||||||
LOG_INFO("WiFi connection lost (reason %u: %s)", reason, disconnectReason(reason));
|
|
||||||
wifi_connect_pending_ = false;
|
|
||||||
} else if (network_iface_ == NetIface::ETHERNET) {
|
|
||||||
LOG_INFO("Ethernet connection lost");
|
|
||||||
ethernet_connect_pending_ = false;
|
|
||||||
}
|
|
||||||
juststopped_ = true;
|
juststopped_ = true;
|
||||||
network_iface_ = NetIface::NONE;
|
|
||||||
network_ip_ = 0;
|
network_ip_ = 0;
|
||||||
has_ipv6_ = false;
|
has_ipv6_ = false;
|
||||||
connect_retry_ = 0;
|
connect_retry_ = 0;
|
||||||
phase_ = initialPhase();
|
if (network_iface_ == NetIface::ETHERNET) {
|
||||||
|
LOG_WARNING("Ethernet connection lost");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
begin();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -543,12 +535,6 @@ void Network::startEthernet() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disabled Ethernet for boards with only 4MB flash and no PSRAM
|
|
||||||
if (ESP.getFlashChipSize() < 4194304 && !ESP.getPsramSize()) { // 4MB
|
|
||||||
LOG_NOTICE("Ethernet disabled for boards with only 4MB flash");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset power and add a delay as ETH doesn't not always start up correctly after a warm boot
|
// reset power and add a delay as ETH doesn't not always start up correctly after a warm boot
|
||||||
if (eth_power_ != -1) {
|
if (eth_power_ != -1) {
|
||||||
pinMode(eth_power_, OUTPUT);
|
pinMode(eth_power_, OUTPUT);
|
||||||
@@ -657,7 +643,9 @@ void Network::findNetworks() {
|
|||||||
} else if (network_iface_ == NetIface::AP) {
|
} else if (network_iface_ == NetIface::AP) {
|
||||||
phase_ = NetPhase::AP;
|
phase_ = NetPhase::AP;
|
||||||
}
|
}
|
||||||
|
if (!ethernet_ever_connected && ethernet_connected()) {
|
||||||
|
ethernet_ever_connected_ = true;
|
||||||
|
}
|
||||||
LOG_INFO("Network connected via %s (IP: " IPSTR ")",
|
LOG_INFO("Network connected via %s (IP: " IPSTR ")",
|
||||||
network_iface_ == NetIface::ETHERNET ? "Ethernet"
|
network_iface_ == NetIface::ETHERNET ? "Ethernet"
|
||||||
: network_iface_ == NetIface::WIFI ? "WiFi"
|
: network_iface_ == NetIface::WIFI ? "WiFi"
|
||||||
@@ -703,18 +691,21 @@ void Network::findNetworks() {
|
|||||||
if (connect_retry_ >= MAX_NETWORK_RECONNECTION_ATTEMPTS && phase_ != NetPhase::AP) {
|
if (connect_retry_ >= MAX_NETWORK_RECONNECTION_ATTEMPTS && phase_ != NetPhase::AP) {
|
||||||
if (phase_ == NetPhase::ETHERNET) {
|
if (phase_ == NetPhase::ETHERNET) {
|
||||||
if (ssid_.isEmpty()) {
|
if (ssid_.isEmpty()) {
|
||||||
LOG_WARNING("Ethernet failed to connect after %u attempts, falling back to AP", connect_retry_);
|
if (!ethernet_ever_connected_) {
|
||||||
phase_ = NetPhase::AP;
|
LOG_WARNING("Ethernet failed to connect after %u attempts, falling back to AP", connect_retry_);
|
||||||
|
phase_ = NetPhase::AP;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING("Ethernet failed to connect after %u attempts, switching to WiFi", connect_retry_);
|
LOG_WARNING("Ethernet failed to connect after %u attempts, switching to WiFi", connect_retry_);
|
||||||
phase_ = NetPhase::WIFI;
|
phase_ = NetPhase::WIFI;
|
||||||
}
|
}
|
||||||
ethernet_connect_pending_ = false;
|
ethernet_connect_pending_ = false;
|
||||||
} else if (phase_ == NetPhase::WIFI) {
|
} else if (phase_ == NetPhase::WIFI) {
|
||||||
LOG_WARNING("WiFi failed to connect after %u attempts, falling back to AP", connect_retry_);
|
if (!wifi_ever_connected_) {
|
||||||
phase_ = NetPhase::AP;
|
LOG_WARNING("WiFi failed to connect after %u attempts, falling back to AP", connect_retry_);
|
||||||
|
phase_ = NetPhase::AP;
|
||||||
|
}
|
||||||
wifi_connect_pending_ = false;
|
wifi_connect_pending_ = false;
|
||||||
WiFi.disconnect(true);
|
|
||||||
}
|
}
|
||||||
connect_retry_ = 0;
|
connect_retry_ = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,8 +204,9 @@ class Network {
|
|||||||
|
|
||||||
NetPhase phase_ = NetPhase::ETHERNET;
|
NetPhase phase_ = NetPhase::ETHERNET;
|
||||||
|
|
||||||
bool wifi_events_registered_ = false; // ensure WiFi.onEvent() handlers are registered only once across begin()/reconnect() cycles
|
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
|
bool wifi_ever_connected_ = false; // set true once we've successfully obtained an IP
|
||||||
|
bool ethernet_ever_connected_ = false; // set true once we've successfully obtained an IP
|
||||||
|
|
||||||
// Network and AP settings
|
// Network and AP settings
|
||||||
bool enableMDNS_;
|
bool enableMDNS_;
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("Sending %s Tx [#%d], telegram: %s",
|
LOG_DEBUG("Sending %s Tx [#%d], telegram: %s",
|
||||||
(telegram->operation != Telegram::Operation::TX_READ) ? ("write") : ("read"),
|
(telegram->operation != Telegram::Operation::TX_READ) ? "write" : "read",
|
||||||
tx_telegram.id_,
|
tx_telegram.id_,
|
||||||
Helpers::data_to_hex(telegram_raw, length - 1).c_str()); // exclude the last CRC byte
|
Helpers::data_to_hex(telegram_raw, length - 1).c_str()); // exclude the last CRC byte
|
||||||
|
|
||||||
@@ -627,7 +627,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s",
|
LOG_DEBUG("Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s",
|
||||||
(operation == Telegram::Operation::TX_WRITE) ? ("Write") : ("Read"),
|
(operation == Telegram::Operation::TX_WRITE) ? "Write" : "Read",
|
||||||
retry_count_,
|
retry_count_,
|
||||||
telegram_last_->to_string().c_str(),
|
telegram_last_->to_string().c_str(),
|
||||||
Helpers::data_to_hex(data, length - 1).c_str());
|
Helpers::data_to_hex(data, length - 1).c_str());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.9.0-dev.8"
|
#define EMSESP_APP_VERSION "3.9.0-dev.9"
|
||||||
|
|||||||
Reference in New Issue
Block a user