Enhancement: add reboot button to nvs editor

The nvs editor will now allow rebooting to the currently active
partition
This commit is contained in:
Sebastien
2019-11-01 10:18:41 -04:00
parent f6d470d266
commit 4df1698722
6 changed files with 32 additions and 10 deletions

View File

@@ -138,12 +138,15 @@ static int restart(int argc, char **argv)
{ {
ESP_LOGW(TAG, "Restarting"); ESP_LOGW(TAG, "Restarting");
esp_restart(); esp_restart();
return 0;
// guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0);
// // If we're still alive, then there may not be an ota partition to boot from
// guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY);
// return 0; // return fail. This should never return... we're rebooting!
} }
void simple_restart()
{
ESP_LOGW(TAG, "Restarting");
esp_restart();
}
esp_err_t guided_restart_ota(){ esp_err_t guided_restart_ota(){
guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0); guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0);
// If we're still alive, then there may not be an ota partition to boot from // If we're still alive, then there may not be an ota partition to boot from

View File

@@ -16,6 +16,7 @@ extern "C" {
void register_system(); void register_system();
esp_err_t guided_factory(); esp_err_t guided_factory();
esp_err_t guided_restart_ota(); esp_err_t guided_restart_ota();
void simple_restart();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -210,7 +210,7 @@ $(document).ready(function(){
console.log('sent config JSON with headers:', autoexec); console.log('sent config JSON with headers:', autoexec);
console.log('now triggering reboot'); console.log('now triggering reboot');
$.ajax({ $.ajax({
url: '/reboot.json', url: '/reboot_ota.json',
dataType: 'text', dataType: 'text',
method: 'POST', method: 'POST',
cache: false, cache: false,
@@ -439,6 +439,9 @@ $(document).ready(function(){
$('#boot-button').on("click", function(){ $('#boot-button').on("click", function(){
enableStatusTimer = true; enableStatusTimer = true;
}); });
$('#reboot-button').on("click", function(){
enableStatusTimer = true;
});
$('#updateAP').on("click", function(){ $('#updateAP').on("click", function(){
refreshAP(true); refreshAP(true);
@@ -656,7 +659,7 @@ function checkStatus(){
$("footer.footer").removeClass('sl'); $("footer.footer").removeClass('sl');
$("footer.footer").addClass('recovery'); $("footer.footer").addClass('recovery');
$("#boot-button").html('Reboot'); $("#boot-button").html('Reboot');
$("#boot-form").attr('action', '/reboot.json'); $("#boot-form").attr('action', '/reboot_ota.json');
enableStatusTimer = true; enableStatusTimer = true;
} else { } else {
recovery = false; recovery = false;

View File

@@ -553,15 +553,25 @@ void http_server_netconn_serve(struct netconn *conn) {
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */ netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
ESP_LOGI(TAG, "http_server_netconn_serve: done serving DELETE /connect.json"); ESP_LOGI(TAG, "http_server_netconn_serve: done serving DELETE /connect.json");
} }
else if(strstr(line, "POST /reboot.json ")) { else if(strstr(line, "POST /reboot_ota.json ")) {
ESP_LOGI(TAG, "http_server_netconn_serve: POST reboot.json"); ESP_LOGI(TAG, "http_server_netconn_serve: POST reboot.json");
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
netconn_close(conn); netconn_close(conn);
netconn_delete(conn); netconn_delete(conn);
guided_restart_ota(); guided_restart_ota();
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST reboot.json"); ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST reboot.json");
} }
else if(strstr(line, "POST /reboot.json ")) {
ESP_LOGI(TAG, "http_server_netconn_serve: POST restart.json");
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
netconn_close(conn);
netconn_delete(conn);
simple_restart();
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST restart.json");
}
else if(strstr(line, "POST /recovery.json ")) { else if(strstr(line, "POST /recovery.json ")) {
ESP_LOGI(TAG, "http_server_netconn_serve: POST recovery.json"); ESP_LOGI(TAG, "http_server_netconn_serve: POST recovery.json");
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
netconn_close(conn); netconn_close(conn);
netconn_delete(conn); netconn_delete(conn);
guided_factory(); guided_factory();

View File

@@ -266,6 +266,11 @@
</tbody> </tbody>
</table> </table>
<div class="buttons"> <div class="buttons">
<div id="boot-div">
<form id="reboot-form" action="/reboot.json" method="post" target="dummyframe">
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
</form>
</div>
<input id="save-nvs" type="button" class="btn btn-success" value="Save" /> <input id="save-nvs" type="button" class="btn btn-success" value="Save" />
</div> </div>
</div> </div>

View File

@@ -60,7 +60,7 @@ void process_autoexec(){
ESP_LOGW(TAG, "Procesing autoexec commands while wifi_manager active. Wifi related commands will be ignored."); ESP_LOGW(TAG, "Procesing autoexec commands while wifi_manager active. Wifi related commands will be ignored.");
} }
#if RECOVERY_APPLICATION #if RECOVERY_APPLICATION
ESP_LOGD(TAG, "Processing autoexec commands in recovery mode. Squeezelite commands will be ignored.") ESP_LOGD(TAG, "Processing autoexec commands in recovery mode. Squeezelite commands will be ignored.");
#endif #endif
if(str_flag !=NULL ){ if(str_flag !=NULL ){