mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 05:27:01 +03:00
Bug Fix: OTA now works from the Squeezelite app partition - release
This commit is contained in:
@@ -474,11 +474,8 @@ void http_server_netconn_serve(struct netconn *conn) {
|
||||
ESP_LOGW(TAG, "Starting process OTA for url %s",otaURL);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Restarting system to process OTA for url %s",otaURL);
|
||||
// close the connection cleanly
|
||||
netconn_close(conn);
|
||||
netconn_delete(conn);
|
||||
#endif
|
||||
start_ota(otaURL,false);
|
||||
wifi_manager_reboot_ota(otaURL);
|
||||
free(otaURL);
|
||||
}
|
||||
}
|
||||
@@ -537,23 +534,23 @@ 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_close(conn);
|
||||
netconn_delete(conn);
|
||||
guided_restart_ota();
|
||||
wifi_manager_reboot(OTA);
|
||||
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");
|
||||
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_delete(conn);
|
||||
simple_restart();
|
||||
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST restart.json");
|
||||
wifi_manager_reboot(RESTART);
|
||||
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST reboot.json");
|
||||
}
|
||||
else if(strstr(line, "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_delete(conn);
|
||||
guided_factory();
|
||||
wifi_manager_reboot(RECOVERY);
|
||||
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST recovery.json");
|
||||
}
|
||||
else if(strstr(line, "GET /status.json ")) {
|
||||
|
||||
@@ -61,6 +61,7 @@ Contains the freeRTOS task and all necessary support
|
||||
#include "driver/adc.h"
|
||||
#include "cJSON.h"
|
||||
#include "nvs_utilities.h"
|
||||
#include "cmd_system.h"
|
||||
|
||||
#ifndef RECOVERY_APPLICATION
|
||||
#define RECOVERY_APPLICATION 0
|
||||
@@ -222,6 +223,35 @@ void wifi_manager_disconnect_async(){
|
||||
//xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_WIFI_DISCONNECT_BIT); TODO: delete
|
||||
}
|
||||
|
||||
void wifi_manager_reboot_ota(char * url){
|
||||
if(url == NULL){
|
||||
wifi_manager_send_message(ORDER_RESTART_OTA, NULL);
|
||||
}
|
||||
else {
|
||||
wifi_manager_send_message(ORDER_RESTART_OTA_URL,strdup(url) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wifi_manager_reboot(reboot_type_t rtype){
|
||||
switch (rtype) {
|
||||
case OTA:
|
||||
wifi_manager_send_message(ORDER_RESTART_OTA, NULL);
|
||||
break;
|
||||
case RECOVERY:
|
||||
wifi_manager_send_message(ORDER_RESTART_RECOVERY, NULL);
|
||||
break;
|
||||
case RESTART:
|
||||
wifi_manager_send_message(ORDER_RESTART, NULL);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG,"Unknown reboot type %d", rtype);
|
||||
break;
|
||||
}
|
||||
wifi_manager_send_message(ORDER_DISCONNECT_STA, NULL);
|
||||
//xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_WIFI_DISCONNECT_BIT); TODO: delete
|
||||
}
|
||||
|
||||
void wifi_manager_init_wifi(){
|
||||
/* event handler and event group for the wifi driver */
|
||||
ESP_LOGD(TAG, "Initializing wifi. Creating event group");
|
||||
@@ -1432,6 +1462,20 @@ void wifi_manager( void * pvParameters ){
|
||||
/* callback */
|
||||
if(cb_ptr_arr[msg.code]) (*cb_ptr_arr[msg.code])(NULL);
|
||||
|
||||
break;
|
||||
case ORDER_RESTART_OTA:
|
||||
guided_restart_ota();
|
||||
break;
|
||||
case ORDER_RESTART_OTA_URL:
|
||||
start_ota(msg.param,false);
|
||||
free(msg.param);
|
||||
break;
|
||||
|
||||
case ORDER_RESTART_RECOVERY:
|
||||
guided_factory();
|
||||
break;
|
||||
case ORDER_RESTART:
|
||||
simple_restart();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -200,10 +200,24 @@ typedef enum message_code_t {
|
||||
EVENT_SCAN_DONE = 13,
|
||||
EVENT_STA_GOT_IP = 14,
|
||||
EVENT_REFRESH_OTA = 15,
|
||||
MESSAGE_CODE_COUNT = 16 /* important for the callback array */
|
||||
ORDER_RESTART_OTA = 16,
|
||||
ORDER_RESTART_RECOVERY = 17,
|
||||
ORDER_RESTART_OTA_URL = 18,
|
||||
ORDER_RESTART = 19,
|
||||
MESSAGE_CODE_COUNT = 20 /* important for the callback array */
|
||||
|
||||
}message_code_t;
|
||||
|
||||
typedef enum reboot_type_t{
|
||||
OTA,
|
||||
RECOVERY,
|
||||
RESTART,
|
||||
} reboot_type_t;
|
||||
void wifi_manager_reboot(reboot_type_t rtype);
|
||||
void wifi_manager_reboot_ota(char * url);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief simplified reason codes for a lost connection.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user