[GH-ISSUE #1291] Using __FlashStringHelper for customHTML #1106

Closed
opened 2026-02-28 01:28:32 +03:00 by kerem · 4 comments
Owner

Originally created by @Mollayo on GitHub (Sep 8, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1291

__FlashStringHelper can be used for customHTML; this is useful for reducing the memory usage of WifiManager. However, this would require to make the following modifications to the WiFiManagerParameter class:

  • Make the _customHTML parameter as protected instead of private.
  • Make the getCustomHTML() method virtual so that this method can be overridden by the child class.

With these modifications, it would then be possible to implement a WiFiManagerParameter child class to implement a CustomHTML that uses __FlashStringHelper. See below.

If you agree, I can implement this feature myself and make a pull request.

String flashStrBuffer;

class FlashCustomHTMLParameter : public WiFiManagerParameter {
public:
    FlashCustomHTMLParameter(const __FlashStringHelper *str):WiFiManagerParameter(NULL)
    {
      _customHTML=(const char*)str;
    }
    const char* getCustomHTML() const {
      // Convert __FlashStringHelper* to const char* using the String class
      flashStrBuffer=(const __FlashStringHelper*)_customHTML;
      return flashStrBuffer.c_str();
    }
};
Originally created by @Mollayo on GitHub (Sep 8, 2021). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1291 __FlashStringHelper can be used for customHTML; this is useful for reducing the memory usage of WifiManager. However, this would require to make the following modifications to the WiFiManagerParameter class: - Make the _customHTML parameter as protected instead of private. - Make the getCustomHTML() method virtual so that this method can be overridden by the child class. With these modifications, it would then be possible to implement a WiFiManagerParameter child class to implement a CustomHTML that uses __FlashStringHelper. See below. If you agree, I can implement this feature myself and make a pull request. ```javascript String flashStrBuffer; class FlashCustomHTMLParameter : public WiFiManagerParameter { public: FlashCustomHTMLParameter(const __FlashStringHelper *str):WiFiManagerParameter(NULL) { _customHTML=(const char*)str; } const char* getCustomHTML() const { // Convert __FlashStringHelper* to const char* using the String class flashStrBuffer=(const __FlashStringHelper*)_customHTML; return flashStrBuffer.c_str(); } }; ```
kerem 2026-02-28 01:28:32 +03:00
Author
Owner

@tablatronix commented on GitHub (Sep 8, 2021):

hmm why did I think this was already supported?

<!-- gh-comment-id:915330018 --> @tablatronix commented on GitHub (Sep 8, 2021): hmm why did I think this was already supported?
Author
Owner

@tablatronix commented on GitHub (Sep 8, 2021):

Can you have this PR ready soon? I need to make a release should I wait ?

<!-- gh-comment-id:915337370 --> @tablatronix commented on GitHub (Sep 8, 2021): Can you have this PR ready soon? I need to make a release should I wait ?
Author
Owner

@Mollayo commented on GitHub (Sep 8, 2021):

Ok. I will do it within today.

<!-- gh-comment-id:915340747 --> @Mollayo commented on GitHub (Sep 8, 2021): Ok. I will do it within today.
Author
Owner

@Mollayo commented on GitHub (Sep 8, 2021):

I just made the pull request.

<!-- gh-comment-id:915353820 --> @Mollayo commented on GitHub (Sep 8, 2021): I just made the pull request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1106
No description provided.