diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index a7f2fae..1975ded 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -259,6 +259,25 @@ void ota_begin() otabuffer+=String("Yes"); otabuffer+=ota_part2_3+ota_part3; otaserver.send(200, "text/html", otabuffer); }); + otaserver.on("/config", HTTP_GET, []() + { + otaserver.sendHeader("Connection", "close"); + String configbuffer = config_part1; + configbuffer += config_part1; + configbuffer+=config_txt_part1+"IP Address"+config_txt_part2+"text"+config_txt_part3+"dev_ip"+config_txt_part4+"dev_ip"+config_txt_part5+IP.toString()+config_txt_part6; + configbuffer+=config_txt_part1+"Network Mask"+config_txt_part2+"text"+config_txt_part3+"netmask"+config_txt_part4+"netmask"+config_txt_part5+IP.toString()+config_txt_part6; + configbuffer+=config_txt_part1+"Gateway"+config_txt_part2+"text"+config_txt_part3+"gateway"+config_txt_part4+"gateway"+config_txt_part5+GATEWAY.toString()+config_txt_part6; + configbuffer+=config_txt_part1+"DNS Server"+config_txt_part2+"text"+config_txt_part3+"dns"+config_txt_part4+"dns"+config_txt_part5+DNS.toString()+config_txt_part6; + configbuffer+=config_txt_part1+"Hostname"+config_txt_part2+"text"+config_txt_part3+"hostname"+config_txt_part4+"hostname"+config_txt_part5+String(HOSTNAME)+config_txt_part6; + configbuffer+=config_txt_part1+"BMS Server - IP Address"+config_txt_part2+"text"+config_txt_part3+"bms_ip"+config_txt_part4+"bms_ip"+config_txt_part5+MQTT_SERVER.toString()+config_txt_part6; + configbuffer+=config_txt_part1+"BMS Server - Port"+config_txt_part2+"text"+config_txt_part3+"bms_port"+config_txt_part4+"bms_port"+config_txt_part5+String(MQTT_PORT)+config_txt_part6; + configbuffer+=config_auth_part1+(MQTT_USE_AUTH?"yes":"no")+config_auth_part2; + configbuffer+=config_txt_part1+"BMS Server - Username"+config_txt_part2+"text"+config_txt_part3+"bms_username"+config_txt_part4+"bms_username"+config_txt_part5+String(MQTT_USERNAME)+config_txt_part6; + configbuffer+=config_txt_part1+"BMS Server - Password"+config_txt_part2+"password"+config_txt_part3+"bms_password"+config_txt_part4+"bms_password"+config_txt_part5+String(MQTT_PASSWORD)+config_txt_part6; + configbuffer+=config_txt_part1+"BMS Server - Endpoint"+config_txt_part2+"text"+config_txt_part3+"bms_endpoint"+config_txt_part4+"bms_endpoint"+config_txt_part5+String(MQTT_BASE_TOPIC)+config_txt_part6; + configbuffer+=config_part2; + otaserver.send(200, "text/html", configbuffer); }); + otaserver.on( "/update", HTTP_POST, []() { diff --git a/src/espmega_iot_ota.cpp b/src/espmega_iot_ota.cpp index f3f1682..3c67154 100644 --- a/src/espmega_iot_ota.cpp +++ b/src/espmega_iot_ota.cpp @@ -14,4 +14,35 @@ const String ota_part2_3 = { }; const String ota_part3 = { #include "ota_html/ota-part3.html" +}; + +const String config_part1 = { +#include "ota_html/config-part1.html" +}; +const String config_part2 = { +#include "ota_html/config-part2.html" +}; +const String config_txt_part1 = { +#include "ota_html/config-textfield-part1.html" +}; +const String config_txt_part2 = { +#include "ota_html/config-textfield-part2.html" +}; +const String config_txt_part3 = { +#include "ota_html/config-textfield-part3.html" +}; +const String config_txt_part4 = { +#include "ota_html/config-textfield-part4.html" +}; +const String config_txt_part5 = { +#include "ota_html/config-textfield-part5.html" +}; +const String config_txt_part6 = { +#include "ota_html/config-textfield-part6.html" +}; +const String config_auth_part1 = { +#include "ota_html/config-auth-part1.html" +}; +const String config_auth_part2 = { +#include "ota_html/config-auth-part2.html" }; \ No newline at end of file diff --git a/src/espmega_iot_ota.hpp b/src/espmega_iot_ota.hpp index 01f62dd..2bd7c4c 100644 --- a/src/espmega_iot_ota.hpp +++ b/src/espmega_iot_ota.hpp @@ -5,3 +5,13 @@ extern const String ota_part2_1; extern const String ota_part2_2; extern const String ota_part2_3; extern const String ota_part3; +extern const String config_part1; +extern const String config_part2; +extern const String config_txt_part1; +extern const String config_txt_part2; +extern const String config_txt_part3; +extern const String config_txt_part4; +extern const String config_txt_part5; +extern const String config_txt_part6; +extern const String config_auth_part1; +extern const String config_auth_part2; diff --git a/src/ota_html/config-auth-part1.html b/src/ota_html/config-auth-part1.html new file mode 100644 index 0000000..4e76dca --- /dev/null +++ b/src/ota_html/config-auth-part1.html @@ -0,0 +1,2 @@ +R"=====()=====" \ No newline at end of file diff --git a/src/ota_html/config-part1.html b/src/ota_html/config-part1.html new file mode 100644 index 0000000..f15e642 --- /dev/null +++ b/src/ota_html/config-part1.html @@ -0,0 +1,4 @@ +R"=====( +
+

ESPMega PRO

+

Device Configurations

)=====" \ No newline at end of file diff --git a/src/ota_html/config copy.html b/src/ota_html/config-part2.html similarity index 58% rename from src/ota_html/config copy.html rename to src/ota_html/config-part2.html index eaacb2f..8b5a3db 100644 --- a/src/ota_html/config copy.html +++ b/src/ota_html/config-part2.html @@ -1,32 +1,5 @@ - - -

ESPMega PRO

-

Device Configurations

-

IP Address

-
-

Network Mask

-
-

Gateway

-
-

DNS Server

-
-

Hostname

-
-

BMS Server - IP Address

-
-

BMS Server - Port

-
- -

BMS Server - Username

-
-

BMS Server - Password

-
-

BMS Server - Endpoint

-
- +R"=====( +

SIWAT SYSTEM 2023
\ No newline at end of file +)=====" \ No newline at end of file diff --git a/src/ota_html/config-textfield-part1.html b/src/ota_html/config-textfield-part1.html new file mode 100644 index 0000000..3c4da03 --- /dev/null +++ b/src/ota_html/config-textfield-part1.html @@ -0,0 +1 @@ +R"=====(

)=====" \ No newline at end of file diff --git a/src/ota_html/config-textfield-part2.html b/src/ota_html/config-textfield-part2.html new file mode 100644 index 0000000..69eaeed --- /dev/null +++ b/src/ota_html/config-textfield-part2.html @@ -0,0 +1,2 @@ +R"=====(

+
)=====" \ No newline at end of file diff --git a/src/ota_html/config.html b/src/ota_html/config.html index eaacb2f..703e086 100644 --- a/src/ota_html/config.html +++ b/src/ota_html/config.html @@ -27,9 +27,13 @@

BMS Server - Endpoint


+

SIWAT SYSTEM 2023