diff --git a/main/main.c b/main/main.c index bbc9720..e762aa9 100755 --- a/main/main.c +++ b/main/main.c @@ -230,6 +230,7 @@ void app_main(void) home_html.html_data = load_html2Ram(home_html); wifi_config_html.html_data = load_html2Ram(wifi_config_html); + upload_ota_html.html_data = load_html2Ram(upload_ota_html); // favicon_ico.html_data = load_html2Ram(favicon_ico); // ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); // ESP_LOGI(TAG,"def_name:%s",Sys_wifi_config.def_AP_Name); diff --git a/main/wifi/wifi_html.c b/main/wifi/wifi_html.c index c4a2b85..24bc6ca 100644 --- a/main/wifi/wifi_html.c +++ b/main/wifi/wifi_html.c @@ -18,16 +18,29 @@ wifi_html_t home_html = { wifi_html_t wifi_config_html = { .html_name = "wifi_config.html", - .html_addr = 0x44b9, + .html_addr = 0x4115, .html_size = 6671, }; +wifi_html_t upload_ota_html = { + .html_name = "upload_script.html", + .html_addr = 0x1b75, + .html_size = 4951, +}; + wifi_html_t favicon_ico = { .html_name = "favicon.ico", .html_addr = 0, .html_size = 106008, }; +static esp_err_t ota_get_handler(httpd_req_t *req) +{ + /* Add file upload form and script which on execution sends a POST request to /upload */ + httpd_resp_set_type(req,HTTPD_TYPE_TEXT); + httpd_resp_send(req, (const char *)upload_ota_html.html_data, upload_ota_html.html_size); + return ESP_OK; +} static esp_err_t index_get_handler(httpd_req_t *req) { @@ -271,6 +284,16 @@ esp_err_t start_web_server(void) }; httpd_register_uri_handler(server, &home_page); + httpd_uri_t ota_page = { + .uri = "/ota", //192.168.1.4 + .method = HTTP_GET, + .handler = ota_get_handler, + /* Let's pass response string in user + * context to demonstrate it's usage */ + .user_ctx = NULL, + }; + httpd_register_uri_handler(server, &ota_page); + httpd_uri_t echo = { .uri = "/config", .method = HTTP_POST, diff --git a/main/wifi/wifi_sta.c b/main/wifi/wifi_sta.c index 32a5402..9e4f612 100644 --- a/main/wifi/wifi_sta.c +++ b/main/wifi/wifi_sta.c @@ -1,5 +1,5 @@ #include "wifi_task.h" - +#include "bsp_flash.h" static const char *TAG = "wifi_sta"; diff --git a/main/wifi/wifi_task.h b/main/wifi/wifi_task.h index 68231ac..6d2c48c 100644 --- a/main/wifi/wifi_task.h +++ b/main/wifi/wifi_task.h @@ -49,6 +49,7 @@ extern wifi_Save_info_t Sys_wifi_config; extern wifi_html_t home_html; extern wifi_html_t wifi_config_html; extern wifi_html_t favicon_ico; +extern wifi_html_t upload_ota_html; void wifi_init_station(void); void wifi_init_softap(void); diff --git a/main/wifi/www/download_html.json b/main/wifi/www/download_html.json index 46e819c..cd1f872 100644 --- a/main/wifi/www/download_html.json +++ b/main/wifi/www/download_html.json @@ -13,7 +13,7 @@ }, { "url": "/upload_script.html", - "size": 5883, + "size": 4951, "name": "upload_script.html", "address": "0x1b75" }, @@ -21,18 +21,18 @@ "url": "/upload_script_copy.html", "size": 3046, "name": "upload_script_copy.html", - "address": "0x3270" + "address": "0x2ecc" }, { "url": "/wifi.html", "size": 1635, "name": "wifi.html", - "address": "0x3e56" + "address": "0x3ab2" }, { "url": "/wifi_config.html", "size": 6671, "name": "wifi_config.html", - "address": "0x44b9" + "address": "0x4115" } ] \ No newline at end of file diff --git a/main/wifi/www/html_files.bin b/main/wifi/www/html_files.bin index 0cea961..b090a8a 100644 --- a/main/wifi/www/html_files.bin +++ b/main/wifi/www/html_files.bin @@ -177,131 +177,167 @@ function upload() {
- +