mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
no wifi disconnect until reboot on ssid cleared
This commit is contained in:
@@ -46,6 +46,7 @@ PButton::PButton() {
|
|||||||
longPressHappened_ = false; // whether or not the hold event happened already
|
longPressHappened_ = false; // whether or not the hold event happened already
|
||||||
vLongPressHappened_ = false; // whether or not the long hold event happened already
|
vLongPressHappened_ = false; // whether or not the long hold event happened already
|
||||||
buttonBusy_ = false; // idle
|
buttonBusy_ = false; // idle
|
||||||
|
pin_ = 255; // undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PButton::init(uint8_t pin, bool pullMode) {
|
bool PButton::init(uint8_t pin, bool pullMode) {
|
||||||
@@ -83,7 +84,7 @@ void PButton::onVLongPress(uint16_t t, buttonEventHandler handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PButton::check(void) {
|
bool PButton::check(void) {
|
||||||
if (!enabled_) {
|
if (!enabled_ || pin_ == 255) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,11 +112,10 @@ class HttpPostEndpoint {
|
|||||||
AsyncJsonResponse * response = new AsyncJsonResponse(false, _bufferSize);
|
AsyncJsonResponse * response = new AsyncJsonResponse(false, _bufferSize);
|
||||||
jsonObject = response->getRoot().to<JsonObject>();
|
jsonObject = response->getRoot().to<JsonObject>();
|
||||||
_statefulService->read(jsonObject, _stateReader);
|
_statefulService->read(jsonObject, _stateReader);
|
||||||
response->setLength();
|
|
||||||
|
|
||||||
if (outcome == StateUpdateResult::CHANGED_RESTART) {
|
if (outcome == StateUpdateResult::CHANGED_RESTART) {
|
||||||
response->setCode(205); // reboot required
|
response->setCode(205); // reboot required
|
||||||
}
|
}
|
||||||
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,10 +28,16 @@ void NetworkSettingsService::begin() {
|
|||||||
WiFi.onEvent(std::bind(&NetworkSettingsService::WiFiEvent, this, _1));
|
WiFi.onEvent(std::bind(&NetworkSettingsService::WiFiEvent, this, _1));
|
||||||
|
|
||||||
_fsPersistence.readFromFS();
|
_fsPersistence.readFromFS();
|
||||||
reconfigureWiFiConnection();
|
// reconfigureWiFiConnection();
|
||||||
|
_lastConnectionAttempt = 0;
|
||||||
|
_stopping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSettingsService::reconfigureWiFiConnection() {
|
void NetworkSettingsService::reconfigureWiFiConnection() {
|
||||||
|
// do not disconnect for switching to eth, restart is needed
|
||||||
|
if (WiFi.isConnected() && _state.ssid.length() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// disconnect and de-configure wifi
|
// disconnect and de-configure wifi
|
||||||
if (WiFi.disconnect(true)) {
|
if (WiFi.disconnect(true)) {
|
||||||
_stopping = true;
|
_stopping = true;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ class NetworkSettings {
|
|||||||
static StateUpdateResult update(JsonObject & root, NetworkSettings & settings) {
|
static StateUpdateResult update(JsonObject & root, NetworkSettings & settings) {
|
||||||
auto enableCORS = settings.enableCORS;
|
auto enableCORS = settings.enableCORS;
|
||||||
auto CORSOrigin = settings.CORSOrigin;
|
auto CORSOrigin = settings.CORSOrigin;
|
||||||
|
auto ssid = settings.ssid;
|
||||||
settings.ssid = root["ssid"] | FACTORY_WIFI_SSID;
|
settings.ssid = root["ssid"] | FACTORY_WIFI_SSID;
|
||||||
settings.bssid = root["bssid"] | "";
|
settings.bssid = root["bssid"] | "";
|
||||||
settings.password = root["password"] | FACTORY_WIFI_PASSWORD;
|
settings.password = root["password"] | FACTORY_WIFI_PASSWORD;
|
||||||
@@ -108,7 +109,7 @@ class NetworkSettings {
|
|||||||
if (settings.staticIPConfig && (IPUtils::isNotSet(settings.localIP) || IPUtils::isNotSet(settings.gatewayIP) || IPUtils::isNotSet(settings.subnetMask))) {
|
if (settings.staticIPConfig && (IPUtils::isNotSet(settings.localIP) || IPUtils::isNotSet(settings.gatewayIP) || IPUtils::isNotSet(settings.subnetMask))) {
|
||||||
settings.staticIPConfig = false;
|
settings.staticIPConfig = false;
|
||||||
}
|
}
|
||||||
if (enableCORS != settings.enableCORS || CORSOrigin != settings.CORSOrigin) {
|
if (enableCORS != settings.enableCORS || CORSOrigin != settings.CORSOrigin || (ssid != settings.ssid && settings.ssid == "")) {
|
||||||
return StateUpdateResult::CHANGED_RESTART; // tell WebUI that a restart is needed
|
return StateUpdateResult::CHANGED_RESTART; // tell WebUI that a restart is needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ build_flags = ${common.build_flags}
|
|||||||
[env:esp32_16M]
|
[env:esp32_16M]
|
||||||
extends = espressi32_base_tasmota
|
extends = espressi32_base_tasmota
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
|
board_build.extra_flags = -DBOARD_HAS_PSRAM
|
||||||
board_upload.flash_size = 16MB
|
board_upload.flash_size = 16MB
|
||||||
board_build.partitions = esp32_partition_16M.csv
|
board_build.partitions = esp32_partition_16M.csv
|
||||||
build_flags = ${common.build_flags}
|
build_flags = ${common.build_flags}
|
||||||
|
|||||||
@@ -1100,6 +1100,10 @@ void Boiler::process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram) {
|
|||||||
*/
|
*/
|
||||||
void Boiler::process_UBATotalUptime(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBATotalUptime(std::shared_ptr<const Telegram> telegram) {
|
||||||
has_update(telegram, UBAuptime_, 0, 3); // force to 3 bytes
|
has_update(telegram, UBAuptime_, 0, 3); // force to 3 bytes
|
||||||
|
// if broadcasted there is no need to fetch
|
||||||
|
if (telegram->dest == 0) {
|
||||||
|
toggle_fetch(0x14, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ void System::wifi_tweak() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for valid ESP32 pins. This is very dependent on which ESP32 board is being used.
|
// check for valid ESP32 pins. This is very dependent on which ESP32 board is being used.
|
||||||
// Typically you can't use 1, 6-11, 12, 14, 15, 20, 24, 28-31 and 40+
|
// Typically you can't use 1, 6-11, 20, 24, 28-31 and 40+
|
||||||
// we allow 0 as it has a special function on the NodeMCU apparently
|
// we allow 0 as it has a special function on the NodeMCU apparently
|
||||||
// See https://diyprojects.io/esp32-how-to-use-gpio-digital-io-arduino-code/#.YFpVEq9KhjG
|
// See https://diyprojects.io/esp32-how-to-use-gpio-digital-io-arduino-code/#.YFpVEq9KhjG
|
||||||
// and https://nodemcu.readthedocs.io/en/dev-esp32/modules/gpio/
|
// and https://nodemcu.readthedocs.io/en/dev-esp32/modules/gpio/
|
||||||
@@ -475,15 +475,16 @@ void System::button_init(bool refresh) {
|
|||||||
reload_settings();
|
reload_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_valid_gpio(pbutton_gpio_)) {
|
if (!is_valid_gpio(pbutton_gpio_)) {
|
||||||
if (!myPButton_.init(pbutton_gpio_, HIGH)) {
|
|
||||||
LOG_DEBUG("Multi-functional button not detected");
|
|
||||||
} else {
|
|
||||||
LOG_DEBUG("Multi-functional button enabled");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOG_WARNING("Invalid button GPIO. Check config.");
|
LOG_WARNING("Invalid button GPIO. Check config.");
|
||||||
|
myPButton_.init(255, HIGH); // disable
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (!myPButton_.init(pbutton_gpio_, HIGH)) {
|
||||||
|
LOG_WARNING("Multi-functional button not detected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG_DEBUG("Multi-functional button enabled");
|
||||||
|
|
||||||
myPButton_.onClick(BUTTON_Debounce, button_OnClick);
|
myPButton_.onClick(BUTTON_Debounce, button_OnClick);
|
||||||
myPButton_.onDblClick(BUTTON_DblClickDelay, button_OnDblClick);
|
myPButton_.onDblClick(BUTTON_DblClickDelay, button_OnDblClick);
|
||||||
@@ -1064,7 +1065,7 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
// see if we're missing a version, will be < 3.5.0b13 from Dec 23 2022
|
// see if we're missing a version, will be < 3.5.0b13 from Dec 23 2022
|
||||||
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
|
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
|
||||||
if (missing_version) {
|
if (missing_version) {
|
||||||
LOG_DEBUG("No version information found (%s)", settingsVersion.c_str());
|
LOG_WARNING("No version information found (%s)", settingsVersion.c_str());
|
||||||
settingsVersion = "3.6.2"; // this was the last stable version
|
settingsVersion = "3.6.2"; // this was the last stable version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1441,7 +1442,7 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
|||||||
} else if (board_profile == "E32") {
|
} else if (board_profile == "E32") {
|
||||||
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32
|
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32
|
||||||
} else if (board_profile == "E32V2") {
|
} else if (board_profile == "E32V2") {
|
||||||
data = {2, 14, 4, 5, 0, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2
|
data = {2, 14, 4, 5, 12, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2
|
||||||
} else if (board_profile == "MH-ET") {
|
} else if (board_profile == "MH-ET") {
|
||||||
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini
|
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini
|
||||||
} else if (board_profile == "NODEMCU") {
|
} else if (board_profile == "NODEMCU") {
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||||
EMSESP::logger().warning("WiFi disconnected. Reason code=%s", disconnectReason(info.wifi_sta_disconnected.reason)); // IDF 4.0
|
EMSESP::logger().warning("WiFi disconnected. Reason: %s (%d)", disconnectReason(info.wifi_sta_disconnected.reason), info.wifi_sta_disconnected.reason); // IDF 4.0
|
||||||
// WiFi.disconnect(true); // this is done in NetworkSettingsService
|
|
||||||
EMSESP::system_.has_ipv6(false);
|
EMSESP::system_.has_ipv6(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -282,6 +281,16 @@ const char * WebStatusService::disconnectReason(uint8_t code) {
|
|||||||
return "assoc fail";
|
return "assoc fail";
|
||||||
case WIFI_REASON_HANDSHAKE_TIMEOUT: // = 204,
|
case WIFI_REASON_HANDSHAKE_TIMEOUT: // = 204,
|
||||||
return "handshake timeout";
|
return "handshake timeout";
|
||||||
|
case WIFI_REASON_CONNECTION_FAIL: // 205,
|
||||||
|
return "connection fail";
|
||||||
|
case WIFI_REASON_AP_TSF_RESET: // 206,
|
||||||
|
return "AP tsf reset";
|
||||||
|
case WIFI_REASON_ROAMING: // 207,
|
||||||
|
return "roaming";
|
||||||
|
case WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG: // 208,
|
||||||
|
return "assoc comeback time too long";
|
||||||
|
case WIFI_REASON_SA_QUERY_TIMEOUT: // 209,
|
||||||
|
return "sa query timeout";
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user