mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
This commit is contained in:
@@ -467,6 +467,9 @@ void MyESP::_OTACallback() {
|
||||
EEPROMr.commit();
|
||||
#endif
|
||||
|
||||
// stop the web server
|
||||
webServer.close();
|
||||
|
||||
if (_ota_pre_callback) {
|
||||
(_ota_pre_callback)(); // call custom function
|
||||
}
|
||||
@@ -1411,14 +1414,14 @@ void MyESP::_mqttConnect() {
|
||||
// Setup everything we need
|
||||
void MyESP::setWIFI(const char * wifi_ssid, const char * wifi_password, wifi_callback_f callback) {
|
||||
// Check SSID too long or missing
|
||||
if (!wifi_ssid || *wifi_ssid == 0x00 || strlen(wifi_ssid) > MAX_STR_LEN) {
|
||||
if (!wifi_ssid || *wifi_ssid == 0x00 || strlen(wifi_ssid) > MAX_SSID_LEN) {
|
||||
_wifi_ssid = NULL;
|
||||
} else {
|
||||
_wifi_ssid = strdup(wifi_ssid);
|
||||
}
|
||||
|
||||
// Check PASS too long
|
||||
if (!wifi_password || *wifi_ssid == 0x00 || strlen(wifi_password) > MAX_STR_LEN) {
|
||||
if (!wifi_password || *wifi_ssid == 0x00 || strlen(wifi_password) > MAX_PWD_LEN) {
|
||||
_wifi_password = NULL;
|
||||
} else {
|
||||
_wifi_password = strdup(wifi_password);
|
||||
@@ -1959,6 +1962,8 @@ void MyESP::_webRootPage() {
|
||||
char s[1000] = {0};
|
||||
|
||||
strlcpy(s, webCommonPage_start, sizeof(s));
|
||||
strlcat(s, webCommonPage_start_refresh, sizeof(s));
|
||||
strlcat(s, webCommonPage_start_body, sizeof(s));
|
||||
|
||||
strlcat(s, "<h1>", sizeof(s));
|
||||
strlcat(s, _app_name, sizeof(s));
|
||||
@@ -2012,6 +2017,7 @@ void MyESP::_webResetPage() {
|
||||
char s[1000] = {0};
|
||||
|
||||
strlcpy(s, webCommonPage_start, sizeof(s));
|
||||
strlcat(s, webCommonPage_start_body, sizeof(s));
|
||||
|
||||
strlcat(s, "<h1>", sizeof(s));
|
||||
strlcat(s, _app_name, sizeof(s));
|
||||
@@ -2039,7 +2045,7 @@ void MyESP::_webResetPage() {
|
||||
} else {
|
||||
// Create a string containing all the arguments
|
||||
// Check to see if there are new values (also doubles to check the length of the new value is long enough)
|
||||
if (webServer.arg("newssid").length() < MAX_STR_LEN) {
|
||||
if (webServer.arg("newssid").length() < MAX_SSID_LEN) {
|
||||
if (webServer.arg("newssid").length() == 0) {
|
||||
_wifi_ssid = NULL;
|
||||
} else {
|
||||
@@ -2047,7 +2053,7 @@ void MyESP::_webResetPage() {
|
||||
}
|
||||
}
|
||||
|
||||
if (webServer.arg("newpassword").length() < MAX_STR_LEN) {
|
||||
if (webServer.arg("newpassword").length() < MAX_PWD_LEN) {
|
||||
if (webServer.arg("newpassword").length() == 0) {
|
||||
_wifi_password = NULL;
|
||||
} else {
|
||||
@@ -2074,6 +2080,7 @@ void MyESP::_webResetAllPage() {
|
||||
char s[1000] = {0};
|
||||
|
||||
strlcpy(s, webCommonPage_start, sizeof(s));
|
||||
strlcat(s, webCommonPage_start_body, sizeof(s));
|
||||
|
||||
strlcat(s, "<h1>", sizeof(s));
|
||||
strlcat(s, _app_name, sizeof(s));
|
||||
|
||||
@@ -192,7 +192,8 @@ constexpr size_t ArraySize(T (&)[N]) {
|
||||
#define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
|
||||
|
||||
// web min and max length of wifi ssid and password
|
||||
#define MAX_STR_LEN 16
|
||||
#define MAX_SSID_LEN 32
|
||||
#define MAX_PWD_LEN 64
|
||||
|
||||
#define MYESP_BOOTUP_FLASHDELAY 50 // flash duration for LED at bootup sequence
|
||||
#define MYESP_BOOTUP_DELAY 2000 // time before we open the window to reset. This is to stop resetting values when uploading firmware via USB
|
||||
@@ -204,15 +205,18 @@ constexpr size_t ArraySize(T (&)[N]) {
|
||||
const char webCommonPage_start[] = "<html>"
|
||||
"<head>"
|
||||
"<style>input {font-size: 1.2em; width: 100%; max-width: 350px; display: block; margin: 5px auto; }"
|
||||
"body {background-color: #FFA500;font: normal 18px Verdana, Arial, sans-serif;} </style>"
|
||||
"<meta http-equiv='refresh' content='5'>"
|
||||
"</head><body>";
|
||||
"body {background-color: #FFA500;font: normal 18px Verdana, Arial, sans-serif;} </style>";
|
||||
|
||||
|
||||
const char webCommonPage_start_refresh[] = "<meta http-equiv='refresh' content='5'>";
|
||||
|
||||
const char webCommonPage_start_body[] = "</head><body>";
|
||||
|
||||
const char webCommonPage_end[] = "</body></html>";
|
||||
|
||||
const char webResetPage_form[] = "<form id='form' action='/reset' method='post'>"
|
||||
"<input name='newssid' type='text' maxlength='16' placeholder='SSID'>"
|
||||
"<input name='newpassword' id='password1' type='password' maxlength='16' placeholder='Password'>"
|
||||
"<input name='newssid' type='text' maxlength='32' placeholder='SSID'>"
|
||||
"<input name='newpassword' id='password1' type='password' maxlength='64' placeholder='Password'>"
|
||||
"<input type='submit' value='Save and reboot'>"
|
||||
"</form>";
|
||||
|
||||
|
||||
@@ -1575,7 +1575,7 @@ void WebCallback(char * body) {
|
||||
char buffer[MYESP_MAXCHARBUFFER] = {0};
|
||||
uint8_t num_devices = ems_printDevices_s(buffer, MYESP_MAXCHARBUFFER);
|
||||
if (num_devices == 0) {
|
||||
strlcat(body, "no compatible EMS devices detected yet. (wait a few seconds)", MYESP_MAXCHARBUFFER);
|
||||
strlcat(body, "(any detected and compatible EMS devices will show up here)", MYESP_MAXCHARBUFFER);
|
||||
} else {
|
||||
strlcat(body, buffer, MYESP_MAXCHARBUFFER);
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
#pragma once
|
||||
|
||||
#define APP_NAME "EMS-ESP"
|
||||
#define APP_VERSION "1.8.1b6"
|
||||
#define APP_VERSION "1.8.1b7"
|
||||
#define APP_HOSTNAME "ems-esp"
|
||||
|
||||
Reference in New Issue
Block a user