mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[PR #1773] WiFiManagerParameter API Changes #1827
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1827
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/tzapu/WiFiManager/pull/1773
Author: @dmadison
Created: 10/30/2024
Status: 🔄 Open
Base:
master← Head:params-api📝 Commits (7)
0df7c77Refactor parameter 'length' as 'maxLength'f75dd98Change param value length function namedd38239Change param getID to getNameb002b03Add setValueReceived function to paramsc781390Remove parameter friendship with WiFiManager2703370Add negative check to param max length246d521Make param destructor virtual📊 Changes
4 files changed (+67 additions, -46 deletions)
View changed files
📝
WiFiManager.cpp(+49 -31)📝
WiFiManager.h(+15 -12)📝
examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino(+1 -1)📝
keywords.txt(+2 -2)📄 Description
This PR makes some small API changes to the
WiFiManagerParameterclass to improve clarity, usability, and encapsulation:Length to Max Length
lengtharguments have been changed tomaxLengthgetValueLength()has been changed togetValueMaxLength()When used as an argument, this refers to the max length of the form and the size of the internal buffer, not the length of the string passed as an argument as expected.
Similarly, the value returned is the max length of the form and the size of the internal buffer, not the length of the value stored.
The internal name (
_length) has not been changed to maintain compatibility with user code, as it's exposed as a protected value. This should be changed in the next major version.ID to Name
getID()has been changed togetName()In HTML forms, names and IDs are two different attributes. Although this value is applied to both, when submitted the form data corresponds to the name, not the ID. This causes confusion if we want the name and ID to differ, since we are currently calling the name the ID internally.
The internal name (
_id) has not been changed to maintain compatibility with user code, as it's exposed as a protected value. This should be changed in the next major version.Value Received Function
setValueReceived()function to receive data from the serverCurrently the user can set the parameter value and max length via the
setValue(const char *defaultValue, int maxLength)function, and inWiFiManager::doParamSave()the server sets the value directly to the buffer pointer using the existing max length.This function provides a standardized way for the server (and any user code) to set a new value while respecting the existing max length value. This is also virtual, so derived parameter classes can intercept the received value and perform additional logic or sanitization if necessary.
WiFiManager friendship removed
There is no reason for the
WiFiManagerclass to have a friendship with the parameter class. The internal calls have been replaced with the corresponding public functions and the friendship has been removed.Incidental Bugfixes
setValue()now checks if a max length argument is negativeWiFiManagerParameter's destructor is now virtualAlthough PR contains API changes there should be no breaking changes. The few items marked deprecated should be removed on the next major release.
If this is merged, here are the changes to make on the next major release:
WiFiManagerParameter::_lengthshould be refactored to_maxLengthWiFiManagerParameter::getValueLength() constshould be removedWiFiManagerParameter::_idshould be refactored to_nameWiFiManagerParameter::getID() constshould be removedThis is a reworked version of PR #1772 that will serve as a basis for other
WiFiManagerParameterrelated PRs.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.