mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge pull request #1661 from MichaelDvP/dev
add telnet command to reboot to previous version #1657
This commit is contained in:
@@ -20,8 +20,10 @@
|
|||||||
- mixer MM100 telegram 0x2CC [#1554](https://github.com/emsesp/EMS-ESP32/issues/1554)
|
- mixer MM100 telegram 0x2CC [#1554](https://github.com/emsesp/EMS-ESP32/issues/1554)
|
||||||
- boiler hpSetDiffPressure [#1563](https://github.com/emsesp/EMS-ESP32/issues/1563)
|
- boiler hpSetDiffPressure [#1563](https://github.com/emsesp/EMS-ESP32/issues/1563)
|
||||||
- custom variables [#1423](https://github.com/emsesp/EMS-ESP32/issues/1423)
|
- custom variables [#1423](https://github.com/emsesp/EMS-ESP32/issues/1423)
|
||||||
- weather compensation [#1642](https://github.com/emsesp/EMS-ESP32/issues/1442)
|
- weather compensation [#1642](https://github.com/emsesp/EMS-ESP32/issues/1642)
|
||||||
- env and partitions for DevKitC-1-N32R8 [#1635](https://github.com/emsesp/EMS-ESP32/discussions/1635)
|
- env and partitions for DevKitC-1-N32R8 [#1635](https://github.com/emsesp/EMS-ESP32/discussions/1635)
|
||||||
|
- command `restart partitionname` and button long press to start with other partition [#1657](https://github.com/emsesp/EMS-ESP32/issues/1657)
|
||||||
|
- command `set service <mqtt|ota|ntp|ap> <enable|disable>` [#1663](https://github.com/emsesp/EMS-ESP32/issues/1663)
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
@@ -45,4 +47,5 @@
|
|||||||
- Length of mqtt Broker adress [#1619](https://github.com/emsesp/EMS-ESP32/issues/1619)
|
- Length of mqtt Broker adress [#1619](https://github.com/emsesp/EMS-ESP32/issues/1619)
|
||||||
- C++ optimizations - see <https://github.com/emsesp/EMS-ESP32/pull/1615>
|
- C++ optimizations - see <https://github.com/emsesp/EMS-ESP32/pull/1615>
|
||||||
- Send MQTT heartbeat immediately after connection [#1628](https://github.com/emsesp/EMS-ESP32/issues/1628)
|
- Send MQTT heartbeat immediately after connection [#1628](https://github.com/emsesp/EMS-ESP32/issues/1628)
|
||||||
- 16MB partitions with second nvs, larger FS, Coredump
|
- 16MB partitions with second nvs, larger FS, Coredump, optional factory partition
|
||||||
|
- stop fetching empty telegrams after 5 min
|
||||||
|
|||||||
9
esp32_partition_16M_factory.csv
Normal file
9
esp32_partition_16M_factory.csv
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9000, 0x005000,
|
||||||
|
otadata, data, ota, , 0x002000,
|
||||||
|
boot, app, factory, , 0x280000,
|
||||||
|
app0, app, ota_0, , 0x590000,
|
||||||
|
app1, app, ota_1, , 0x590000,
|
||||||
|
nvs1, data, nvs, , 0x040000,
|
||||||
|
spiffs, data, spiffs, , 0x200000,
|
||||||
|
coredump, data, coredump,, 0x010000,
|
||||||
|
@@ -198,8 +198,16 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
commands->add_command(ShellContext::MAIN, CommandFlags::ADMIN, string_vector{F_(restart)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
commands->add_command(ShellContext::MAIN,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
string_vector{F_(restart)},
|
||||||
|
string_vector{F_(partitionname_optional)},
|
||||||
|
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
|
if (arguments.size()) {
|
||||||
|
to_app(shell).system_.system_restart(arguments.front().c_str());
|
||||||
|
} else {
|
||||||
to_app(shell).system_.system_restart();
|
to_app(shell).system_.system_restart();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
commands->add_command(ShellContext::MAIN,
|
commands->add_command(ShellContext::MAIN,
|
||||||
@@ -344,6 +352,43 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
to_app(shell).uart_init();
|
to_app(shell).uart_init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commands->add_command(ShellContext::MAIN,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
string_vector{F_(set), F_(service)},
|
||||||
|
string_vector{F_(service_mandatory), F_(enable_mandatory)},
|
||||||
|
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
|
if (arguments.back() == "enable" || arguments.back() == "disable") {
|
||||||
|
bool enable = arguments.back() == "enable";
|
||||||
|
if (arguments.front() == "mqtt") {
|
||||||
|
to_app(shell).esp8266React.getMqttSettingsService()->update([&](MqttSettings & Settings) {
|
||||||
|
Settings.enabled = enable;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
});
|
||||||
|
} else if (arguments.front() == "ota") {
|
||||||
|
to_app(shell).esp8266React.getOTASettingsService()->update([&](OTASettings & Settings) {
|
||||||
|
Settings.enabled = enable;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
});
|
||||||
|
} else if (arguments.front() == "ntp") {
|
||||||
|
to_app(shell).esp8266React.getNTPSettingsService()->update([&](NTPSettings & Settings) {
|
||||||
|
Settings.enabled = enable;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
});
|
||||||
|
} else if (arguments.front() == "ap") {
|
||||||
|
to_app(shell).esp8266React.getAPSettingsService()->update([&](APSettings & Settings) {
|
||||||
|
Settings.provisionMode = enable ? 0 : 2;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
shell.printfln("unknown service: %s", arguments.front().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shell.printfln("service '%s' %sd", arguments.front().c_str(), arguments.back().c_str());
|
||||||
|
} else {
|
||||||
|
shell.println("Must be `enable` or `disable`");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
// EMS device commands
|
// EMS device commands
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1819,8 +1819,11 @@ bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("This telegram (%s) is not recognized by the EMS bus", tf.telegram_type_name_);
|
EMSESP::logger().debug("This telegram (%s) is not recognized by the EMS bus", tf.telegram_type_name_);
|
||||||
#endif
|
#endif
|
||||||
// removing fetch causes issue: https://github.com/emsesp/EMS-ESP32/issues/1420
|
// removing fetch after start causes issue: https://github.com/emsesp/EMS-ESP32/issues/1420
|
||||||
// tf.fetch_ = false;
|
// continue retry the first 5 minutes, then disable (added 15.3.2024)
|
||||||
|
if (uuid::get_uptime_sec() > 600) {
|
||||||
|
tf.fetch_ = false;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (telegram->message_length > 0) {
|
if (telegram->message_length > 0) {
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
#include "emsesp.h"
|
#include "emsesp.h"
|
||||||
|
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
#include "esp_ota_ops.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static_assert(uuid::thread_safe, "uuid-common must be thread-safe");
|
static_assert(uuid::thread_safe, "uuid-common must be thread-safe");
|
||||||
static_assert(uuid::log::thread_safe, "uuid-log must be thread-safe");
|
static_assert(uuid::log::thread_safe, "uuid-log must be thread-safe");
|
||||||
static_assert(uuid::console::thread_safe, "uuid-console must be thread-safe");
|
static_assert(uuid::console::thread_safe, "uuid-console must be thread-safe");
|
||||||
@@ -1488,9 +1492,14 @@ void EMSESP::start() {
|
|||||||
|
|
||||||
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
||||||
|
|
||||||
nvs_.begin("ems-esp", false, "nvs");
|
if (!nvs_.begin("ems-esp", false, "nvs1")) { // try bigger nvs partition on 16M flash first
|
||||||
|
nvs_.begin("ems-esp", false, "nvs"); // fallback to small nvs
|
||||||
|
}
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
LOG_INFO("Starting EMS-ESP version %s from partition %s", EMSESP_APP_VERSION, esp_ota_get_running_partition()->label); // welcome message
|
||||||
|
#else
|
||||||
LOG_INFO("Starting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
LOG_INFO("Starting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
||||||
|
#endif
|
||||||
LOG_DEBUG("System is running in Debug mode");
|
LOG_DEBUG("System is running in Debug mode");
|
||||||
LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ MAKE_WORD(users)
|
|||||||
MAKE_WORD(publish)
|
MAKE_WORD(publish)
|
||||||
MAKE_WORD(board_profile)
|
MAKE_WORD(board_profile)
|
||||||
MAKE_WORD(setvalue)
|
MAKE_WORD(setvalue)
|
||||||
|
MAKE_WORD(service)
|
||||||
|
|
||||||
// for commands
|
// for commands
|
||||||
MAKE_WORD(call)
|
MAKE_WORD(call)
|
||||||
@@ -140,6 +141,7 @@ MAKE_WORD_CUSTOM(asterisks, "********")
|
|||||||
MAKE_WORD_CUSTOM(n_mandatory, "<n>")
|
MAKE_WORD_CUSTOM(n_mandatory, "<n>")
|
||||||
MAKE_WORD_CUSTOM(sensorid_optional, "[sensor ID]")
|
MAKE_WORD_CUSTOM(sensorid_optional, "[sensor ID]")
|
||||||
MAKE_WORD_CUSTOM(id_optional, "[id|hc]")
|
MAKE_WORD_CUSTOM(id_optional, "[id|hc]")
|
||||||
|
MAKE_WORD_CUSTOM(partitionname_optional, "[partitionsname]")
|
||||||
MAKE_WORD_CUSTOM(data_optional, "[data]")
|
MAKE_WORD_CUSTOM(data_optional, "[data]")
|
||||||
MAKE_WORD_CUSTOM(nvs_optional, "[nvs]")
|
MAKE_WORD_CUSTOM(nvs_optional, "[nvs]")
|
||||||
MAKE_WORD_CUSTOM(offset_optional, "[offset]")
|
MAKE_WORD_CUSTOM(offset_optional, "[offset]")
|
||||||
@@ -155,6 +157,8 @@ MAKE_WORD_CUSTOM(new_password_prompt1, "Enter new password: ")
|
|||||||
MAKE_WORD_CUSTOM(new_password_prompt2, "Retype new password: ")
|
MAKE_WORD_CUSTOM(new_password_prompt2, "Retype new password: ")
|
||||||
MAKE_WORD_CUSTOM(password_prompt, "Password: ")
|
MAKE_WORD_CUSTOM(password_prompt, "Password: ")
|
||||||
MAKE_WORD_CUSTOM(unset, "<unset>")
|
MAKE_WORD_CUSTOM(unset, "<unset>")
|
||||||
|
MAKE_WORD_CUSTOM(enable_mandatory, "<enable | disable>")
|
||||||
|
MAKE_WORD_CUSTOM(service_mandatory, "<ota | ap | mqtt | ntp>")
|
||||||
|
|
||||||
// more common names that don't need translations
|
// more common names that don't need translations
|
||||||
MAKE_NOTRANSLATION(1x3min, "1x3min")
|
MAKE_NOTRANSLATION(1x3min, "1x3min")
|
||||||
|
|||||||
@@ -261,12 +261,40 @@ void System::store_nvs_values() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restart EMS-ESP
|
// restart EMS-ESP
|
||||||
void System::system_restart() {
|
void System::system_restart(const char * partitionname) {
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
if (partitionname != nullptr) {
|
||||||
|
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||||
|
if (partition && strcmp(partition->label, partitionname) == 0) {
|
||||||
|
esp_ota_set_boot_partition(partition);
|
||||||
|
} else if (strcmp(esp_ota_get_running_partition()->label, partitionname) != 0) {
|
||||||
|
partition = esp_ota_get_next_update_partition(NULL);
|
||||||
|
if (!partition) {
|
||||||
|
LOG_ERROR("Partition '%s' not found", partitionname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strcmp(partition->label, partitionname) != 0 && strcmp(partitionname, "boot") != 0) {
|
||||||
|
partition = esp_ota_get_next_update_partition(partition);
|
||||||
|
if (!partition || strcmp(partition->label, partitionname)) {
|
||||||
|
LOG_ERROR("Partition '%s' not found", partitionname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint64_t buffer;
|
||||||
|
esp_partition_read(partition, 0, &buffer, 8);
|
||||||
|
if (buffer == 0xFFFFFFFFFFFFFFFF) { // partition empty
|
||||||
|
LOG_ERROR("Partition '%s' is empty, not bootable", partition->label);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
esp_ota_set_boot_partition(partition);
|
||||||
|
}
|
||||||
|
LOG_INFO("Restarting EMS-ESP from partition '%s'", partitionname);
|
||||||
|
} else {
|
||||||
LOG_INFO("Restarting EMS-ESP...");
|
LOG_INFO("Restarting EMS-ESP...");
|
||||||
|
}
|
||||||
store_nvs_values();
|
store_nvs_values();
|
||||||
Shell::loop_all();
|
Shell::loop_all();
|
||||||
delay(1000); // wait a second
|
delay(1000); // wait a second
|
||||||
#ifndef EMSESP_STANDALONE
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -458,7 +486,8 @@ void System::button_OnDblClick(PButton & b) {
|
|||||||
|
|
||||||
// button long press
|
// button long press
|
||||||
void System::button_OnLongPress(PButton & b) {
|
void System::button_OnLongPress(PButton & b) {
|
||||||
LOG_NOTICE("Button pressed - long press");
|
LOG_NOTICE("Button pressed - long press - restart other partition");
|
||||||
|
EMSESP::system_.system_restart("boot");
|
||||||
}
|
}
|
||||||
|
|
||||||
// button indefinite press
|
// button indefinite press
|
||||||
@@ -1511,9 +1540,13 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// restart command - perform a hard reset by setting flag
|
// restart command - perform a hard reset
|
||||||
bool System::command_restart(const char * value, const int8_t id) {
|
bool System::command_restart(const char * value, const int8_t id) {
|
||||||
restart_requested(true);
|
if (value != nullptr && value[0] == '\0') {
|
||||||
|
EMSESP::system_.system_restart(value);
|
||||||
|
} else {
|
||||||
|
EMSESP::system_.system_restart();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class System {
|
|||||||
std::string reset_reason(uint8_t cpu) const;
|
std::string reset_reason(uint8_t cpu) const;
|
||||||
|
|
||||||
void store_nvs_values();
|
void store_nvs_values();
|
||||||
void system_restart();
|
void system_restart(const char * partition = nullptr);
|
||||||
void format(uuid::console::Shell & shell);
|
void format(uuid::console::Shell & shell);
|
||||||
void upload_status(bool in_progress);
|
void upload_status(bool in_progress);
|
||||||
bool upload_status();
|
bool upload_status();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.6.5-dev.17"
|
#define EMSESP_APP_VERSION "3.6.5-dev.18"
|
||||||
|
|||||||
Reference in New Issue
Block a user