khoih-prog / ESP_WiFiManager_Lite

Light-Weight MultiWiFi/Credentials Manager for ESP32 (including ESP32-S2 and ESP32-C3) and ESP8266 boards boards. Powerful-yet-simple-to-use feature to enable adding dynamic custom parameters. paragraph=Library to configure MultiWiFi/Credentials at runtime for ESP32/ESP8266 boards. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS, SPIFFS or EEPROM. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. Double or MultiDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested.
MIT License
49 stars 15 forks source link

move HTML char* into PROGMEM #35

Closed hmueller01 closed 1 year ago

hmueller01 commented 1 year ago

There was a little bit more to do than just uncomment the /*PROGMEM*/ pragma. All PROGMEM vars must be 32-bit aligned to avoid exceptions. That's what FPSTR() does.

khoih-prog commented 1 year ago

HI @hmueller01

Thanks for the PR.

There is many compiler warnings/errors as follows, please clean them up.

I'm using

In file included from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/defines.h:139,
                 from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/ESP_WiFi.ino:13:
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:125:8: warning: #warning Using ESP32 Core 1.0.6 or 2.0.0+ [-Wcpp]
       #warning Using ESP32 Core 1.0.6 or 2.0.0+
        ^~~~~~~
In file included from /home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:278,
                 from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/defines.h:139,
                 from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/ESP_WiFi.ino:13:
/home/kh/Arduino/libraries/ESP_MultiResetDetector-1.3.2/src/ESP_MultiResetDetector.h:110:10: warning: #warning Using ESP32 Core 1.0.6 or 2.0.0+ [-Wcpp]
         #warning Using ESP32 Core 1.0.6 or 2.0.0+
          ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/defines.h:139,
                 from /home/kh/Arduino/khoih-prog_working/ESP_WiFiManager_Lite_GitHub/examples/ESP_WiFi/ESP_WiFi.ino:13:
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h: In member function 'void ESP_WiFiManager_Lite::createHTML(String&)':
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:86: error: conversion from 'const __FlashStringHelper*' to 'const StringSumHelper' is ambiguous
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                                                                                      ^
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:393:9: note: candidate: 'StringSumHelper::StringSumHelper(long long unsigned int)' <near match>
         StringSumHelper(unsigned long long num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:393:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'long long unsigned int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:390:9: note: candidate: 'StringSumHelper::StringSumHelper(long long int)' <near match>
         StringSumHelper(long long num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:390:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'long long int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:381:9: note: candidate: 'StringSumHelper::StringSumHelper(long unsigned int)' <near match>
         StringSumHelper(unsigned long num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:381:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'long unsigned int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:378:9: note: candidate: 'StringSumHelper::StringSumHelper(long int)' <near match>
         StringSumHelper(long num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:378:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'long int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:375:9: note: candidate: 'StringSumHelper::StringSumHelper(unsigned int)' <near match>
         StringSumHelper(unsigned int num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:375:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'unsigned int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:372:9: note: candidate: 'StringSumHelper::StringSumHelper(int)' <near match>
         StringSumHelper(int num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:372:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'int' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:369:9: note: candidate: 'StringSumHelper::StringSumHelper(unsigned char)' <near match>
         StringSumHelper(unsigned char num) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:369:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'unsigned char' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:366:9: note: candidate: 'StringSumHelper::StringSumHelper(char)' <near match>
         StringSumHelper(char c) :
         ^~~~~~~~~~~~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:366:9: note:   conversion of argument 1 would be ill-formed:
In file included from /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/Arduino.h:166,
                 from sketch/ESP_WiFi.ino.cpp:1:
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:39:30: error: invalid conversion from 'const __FlashStringHelper*' to 'char' [-fpermissive]
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kh/Arduino/libraries/ESP_WiFiManager_Lite-1.10.3/src/ESP_WiFiManager_Lite.h:2662:24: note: in expansion of macro 'FPSTR'
         ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
                        ^~~~~
/home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/cores/esp32/WString.h:186:34: note:   initializing argument 1 of 'StringSumHelper& operator+(const StringSumHelper&, const String&)'
         friend StringSumHelper & operator +(const StringSumHelper &lhs, const String &rhs);
                                  ^~~~~~~~
Multiple libraries were found for "WiFi.h"
 Used: /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/libraries/WiFi
 Not used: /home/kh/Downloads/Arduino/arduino-1.8.19/libraries/WiFi
 Not used: /home/kh/Arduino/libraries/Seeed_Arduino_WiFi_v1-0-2
 Not used: /home/kh/Arduino/libraries/WiFiNINA
 Not used: /home/kh/Arduino/libraries/WiFiEspAT
Multiple libraries were found for "WebServer.h"
 Used: /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/libraries/WebServer
 Not used: /home/kh/Arduino/libraries/Seeed_Arduino_WiFi_v1-0-2
Multiple libraries were found for "DNSServer.h"
 Used: /home/kh/.arduino15/packages/esp32/hardware/esp32/2.0.6/libraries/DNSServer
 Not used: /home/kh/Arduino/libraries/Seeed_Arduino_WiFi_v1-0-2
exit status 1
Error compiling for board ESP32 Dev Module.
khoih-prog commented 1 year ago

You can just change to

ListOfSSIDs += String(FPSTR(ESP_WM_LITE_OPTION_START)) + String(WiFi.SSID(indices[i])) + String(FPSTR(ESP_WM_LITE_OPTION_END));

from

ListOfSSIDs += FPSTR(ESP_WM_LITE_OPTION_START) + String(WiFi.SSID(indices[i])) + FPSTR(ESP_WM_LITE_OPTION_END);
khoih-prog commented 1 year ago

HI @hmueller01

I modified the code as I think you're busy now. Merging now.

Thanks,

hmueller01 commented 1 year ago

I compiled with ESP8266 environment and had no warning. I forgot to test with ESP32 and your examples. Sorry. Tx for fixing!

khoih-prog commented 1 year ago

Thanks for your good works. Waiting for your PROGMEM PRs for the ESPAsync_WiFiManager_Lite library, and even many more.

Now I hope you could start experiencing the time-consuming and having to pay attention to all aspects when managing libraries, especially multi-function, multi-platform ones. You'll certainly do much better work in the future.

khoih-prog commented 1 year ago

Hi @hmueller01

The new ESP_WiFiManager_Lite releases v1.10.4 has just been published. Your contribution is added to the longer-everyday list in Contributions and Thanks

Best Regards,


Release v1.10.4

  1. Using PROGMEM for HTML strings. Check move HTML char* into PROGMEM #35