Update String allocation

pull/41/head
Hieromon Ikasamo 6 years ago
parent 7d5bed6183
commit 48c6ea8b4e
  1. 16
      src/AutoConnect.cpp
  2. 5
      src/AutoConnectDefs.h

@ -51,7 +51,7 @@ void AutoConnect::_initialize() {
_rfReset = false; _rfReset = false;
_responsePage = nullptr; _responsePage = nullptr;
_currentPageElement = nullptr; _currentPageElement = nullptr;
_menuTitle = String(AUTOCONNECT_MENU_TITLE); _menuTitle = String(F(AUTOCONNECT_MENU_TITLE));
_connectTimeout = AUTOCONNECT_TIMEOUT; _connectTimeout = AUTOCONNECT_TIMEOUT;
memset(&_credential, 0x00, sizeof(struct station_config)); memset(&_credential, 0x00, sizeof(struct station_config));
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
@ -450,7 +450,7 @@ void AutoConnect::handleRequest() {
if (WiFi.BSSID() != NULL) { if (WiFi.BSSID() != NULL) {
memcpy(_credential.bssid, WiFi.BSSID(), sizeof(station_config::bssid)); memcpy(_credential.bssid, WiFi.BSSID(), sizeof(station_config::bssid));
_currentHostIP = WiFi.localIP(); _currentHostIP = WiFi.localIP();
_redirectURI = String(AUTOCONNECT_URI_SUCCESS); _redirectURI = String(F(AUTOCONNECT_URI_SUCCESS));
// Save current credential // Save current credential
if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) { if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) {
@ -467,7 +467,7 @@ void AutoConnect::handleRequest() {
} }
else { else {
_currentHostIP = WiFi.softAPIP(); _currentHostIP = WiFi.softAPIP();
_redirectURI = String(AUTOCONNECT_URI_FAIL); _redirectURI = String(F(AUTOCONNECT_URI_FAIL));
_rsConnect = WiFi.status(); _rsConnect = WiFi.status();
_disconnectWiFi(false); _disconnectWiFi(false);
while (WiFi.status() != WL_IDLE_STATUS && WiFi.status() != WL_DISCONNECTED) { while (WiFi.status() != WL_IDLE_STATUS && WiFi.status() != WL_DISCONNECTED) {
@ -598,9 +598,9 @@ void AutoConnect::_stopPortal() {
bool AutoConnect::_captivePortal() { bool AutoConnect::_captivePortal() {
String hostHeader = _webServer->hostHeader(); String hostHeader = _webServer->hostHeader();
if (!_isIP(hostHeader) && (hostHeader != WiFi.localIP().toString())) { if (!_isIP(hostHeader) && (hostHeader != WiFi.localIP().toString())) {
String location = String("http://") + _webServer->client().localIP().toString() + String(AUTOCONNECT_URI); String location = String(F("http://")) + _webServer->client().localIP().toString() + String(AUTOCONNECT_URI);
_webServer->sendHeader("Location", location, true); _webServer->sendHeader(F("Location"), location, true);
_webServer->send(302, "text/plain", ""); _webServer->send(302, F("text/plain"), "");
_webServer->client().flush(); _webServer->client().flush();
_webServer->client().stop(); _webServer->client().stop();
return true; return true;
@ -666,7 +666,7 @@ void AutoConnect::_handleNotFound() {
*/ */
String AutoConnect::_induceReset(PageArgument& args) { String AutoConnect::_induceReset(PageArgument& args) {
_rfReset = true; _rfReset = true;
return String("Reset in progress..."); return String(F("Reset in progress..."));
} }
/** /**
@ -706,7 +706,7 @@ String AutoConnect::_induceConnect(PageArgument& args) {
// Turn on the trigger to start WiFi.begin(). // Turn on the trigger to start WiFi.begin().
_rfConnect = true; _rfConnect = true;
_menuTitle = String("Connecting"); _menuTitle = String(F(AUTOCONNECT_CONNECTING_TITLE));
// Since v0.9.7, the redirect method changed from a 302 response to the // Since v0.9.7, the redirect method changed from a 302 response to the
// meta tag with refresh attribute. // meta tag with refresh attribute.

@ -76,6 +76,11 @@
#define AUTOCONNECT_MENU_TITLE "AutoConnect" #define AUTOCONNECT_MENU_TITLE "AutoConnect"
#endif // !AUTOCONNECT_MENU_TITLE #endif // !AUTOCONNECT_MENU_TITLE
// AutoConnect title for during a connection attempting
#ifndef AUTOCONNECT_CONNECTING_TITLE
#define AUTOCONNECT_CONNECTING_TITLE "Connecting"
#endif // !AUTOCONNECT_CONNECTING_TITLE
// URIs of AutoConnect menu collection // URIs of AutoConnect menu collection
#define AUTOCONNECT_URI_CONFIG AUTOCONNECT_URI "/config" #define AUTOCONNECT_URI_CONFIG AUTOCONNECT_URI "/config"
#define AUTOCONNECT_URI_CONNECT AUTOCONNECT_URI "/connect" #define AUTOCONNECT_URI_CONNECT AUTOCONNECT_URI "/connect"

Loading…
Cancel
Save