mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add restart other command to change partition #1657
This commit is contained in:
@@ -20,8 +20,9 @@
|
||||
- mixer MM100 telegram 0x2CC [#1554](https://github.com/emsesp/EMS-ESP32/issues/1554)
|
||||
- boiler hpSetDiffPressure [#1563](https://github.com/emsesp/EMS-ESP32/issues/1563)
|
||||
- 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)
|
||||
- command `restart other` and button long press to start with other partition [#1657](https://github.com/emsesp/EMS-ESP32/issues/1657)
|
||||
|
||||
## Fixed
|
||||
|
||||
|
||||
@@ -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_(other_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size()) {
|
||||
to_app(shell).system_.system_restart(arguments.front() == "other");
|
||||
} else {
|
||||
to_app(shell).system_.system_restart();
|
||||
}
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
|
||||
@@ -140,6 +140,7 @@ MAKE_WORD_CUSTOM(asterisks, "********")
|
||||
MAKE_WORD_CUSTOM(n_mandatory, "<n>")
|
||||
MAKE_WORD_CUSTOM(sensorid_optional, "[sensor ID]")
|
||||
MAKE_WORD_CUSTOM(id_optional, "[id|hc]")
|
||||
MAKE_WORD_CUSTOM(other_optional, "[other]")
|
||||
MAKE_WORD_CUSTOM(data_optional, "[data]")
|
||||
MAKE_WORD_CUSTOM(nvs_optional, "[nvs]")
|
||||
MAKE_WORD_CUSTOM(offset_optional, "[offset]")
|
||||
|
||||
@@ -261,12 +261,31 @@ void System::store_nvs_values() {
|
||||
}
|
||||
|
||||
// restart EMS-ESP
|
||||
void System::system_restart() {
|
||||
void System::system_restart(const bool other_partition) {
|
||||
if (other_partition) {
|
||||
LOG_INFO("Restarting EMS-ESP to other partition...");
|
||||
} else {
|
||||
LOG_INFO("Restarting EMS-ESP...");
|
||||
}
|
||||
|
||||
store_nvs_values();
|
||||
Shell::loop_all();
|
||||
delay(1000); // wait a second
|
||||
#ifndef EMSESP_STANDALONE
|
||||
if (other_partition) {
|
||||
// check for factory partiton
|
||||
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||
if (!partition) {
|
||||
partition = esp_ota_get_next_update_partition(NULL);
|
||||
}
|
||||
if (partition) {
|
||||
uint64_t buffer;
|
||||
esp_partition_read(partition, 0, &buffer, 8);
|
||||
if (buffer != 0xFFFFFFFFFFFFFFFF) { // partition not empty
|
||||
esp_ota_set_boot_partition(partition);
|
||||
}
|
||||
}
|
||||
}
|
||||
ESP.restart();
|
||||
#endif
|
||||
}
|
||||
@@ -458,7 +477,8 @@ void System::button_OnDblClick(PButton & b) {
|
||||
|
||||
// button long press
|
||||
void System::button_OnLongPress(PButton & b) {
|
||||
LOG_NOTICE("Button pressed - long press");
|
||||
LOG_NOTICE("Button pressed - long press - boot to other partition");
|
||||
EMSESP::system_.system_restart(true);
|
||||
}
|
||||
|
||||
// button indefinite press
|
||||
@@ -1511,9 +1531,13 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
||||
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) {
|
||||
restart_requested(true);
|
||||
if (value[0] == '1' || strcmp(value, "true") == 0 || strcmp(value, "other") == 0) {
|
||||
EMSESP::system_.system_restart(true);
|
||||
} else {
|
||||
EMSESP::system_.system_restart(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class System {
|
||||
std::string reset_reason(uint8_t cpu) const;
|
||||
|
||||
void store_nvs_values();
|
||||
void system_restart();
|
||||
void system_restart(const bool other_partition = false);
|
||||
void format(uuid::console::Shell & shell);
|
||||
void upload_status(bool in_progress);
|
||||
bool upload_status();
|
||||
|
||||
Reference in New Issue
Block a user