trigger reboot if autoexec1 has changed

This commit is contained in:
Christian Herzog
2019-09-18 19:38:08 +02:00
parent 37f8ef3203
commit 157428ba8f

View File

@@ -265,8 +265,10 @@ void http_server_netconn_serve(struct netconn *conn) {
i++; i++;
} while(1); } while(1);
free(buff); free(buff);
netconn_write(conn, json_end, strlen(json_end), NETCONN_NOCOPY); netconn_write(conn, json_end, strlen(json_end), NETCONN_NOCOPY);
ESP_LOGD(TAG,"%s", json_end); ESP_LOGD(TAG,"%s", json_end);
} }
} }
else if(strstr(line, "POST /factory.json ")){ else if(strstr(line, "POST /factory.json ")){
@@ -304,7 +306,6 @@ void http_server_netconn_serve(struct netconn *conn) {
ESP_LOGD(TAG,"Looking for command name %s.", autoexec_name); ESP_LOGD(TAG,"Looking for command name %s.", autoexec_name);
autoexec_value = http_server_get_header(save_ptr, autoexec_name, &lenS); autoexec_value = http_server_get_header(save_ptr, autoexec_name, &lenS);
if(autoexec_value ){ if(autoexec_value ){
if(lenS < MAX_COMMAND_LINE_SIZE ){ if(lenS < MAX_COMMAND_LINE_SIZE ){
ESP_LOGD(TAG, "http_server_netconn_serve: config.json/ call, with %s: %s, length %i", autoexec_key, autoexec_value, lenS); ESP_LOGD(TAG, "http_server_netconn_serve: config.json/ call, with %s: %s, length %i", autoexec_key, autoexec_value, lenS);
@@ -323,6 +324,11 @@ 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); //200ok netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); //200ok
//reboot esp if autoexec1 was modified
if (i > 1) {
ESP_LOGD(TAG,"autoexec1 changed, triggering reboot");
esp_restart();
}
} }
else{ else{
netconn_write(conn, http_503_hdr, sizeof(http_503_hdr) - 1, NETCONN_NOCOPY); netconn_write(conn, http_503_hdr, sizeof(http_503_hdr) - 1, NETCONN_NOCOPY);