mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #134] Add boolean parameters. #102
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#102
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?
Originally created by @fngstudios on GitHub (Mar 23, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/134
Hi, thank you for your great library, I am using it in every esp8266 project.
It would be nice to add different types of parameters, mainly boolean parameters so the user could choose wich parameters they want to use. In my case I have a standard node which can send a variety of parameters but each node actually send only one or two of those parameters. With boolean parameters in the configuration portal the user may specify which parameter the node will send and in the main code the program read only those parameters from the sensors. I have made some changes to enable this in my local repo, but it is an ugly hack and I was waiting for you to add the custom CSS option to do this in a more elegant and efficient way. If you want I could do a pull request with my changes.
Thank you again.
@tzapu commented on GitHub (Mar 23, 2016):
hi, custom css is there in the latest github
there is also the ability to add custom html to the configuration form, but it won t save those parameters as it doesn t know they exist yet...
i m not entirely sure how i would go about saving custom params, as they could be anything (you only want 2 options, but the next user might want 3 or 4)
ideas are welcome :)
@fngstudios commented on GitHub (Mar 24, 2016):
Hi, I really don't know if my idea would be useful to anyone besides me, thats why I asked.
Imagine you have a "standard" board which can send a number of parameters, temperature, digital inputs, i2c sensor data, etc. But the user only connect one or two sensors, in the code you have all those possible parameters declared as booleans so in the configuration portal they select which parameters they want to use and then in the code you can read and send to the server only those sensors.
The boolean parameters appear as checkboxes in the configuration portal with a label.
Sorry for my bad english.
@dronov commented on GitHub (Aug 7, 2017):
Hello @fngstudios
Could you make the PR to show how you solved your task?
I think that boolean parameters at the configuration portal will be useful for others. Yeas, we have an ability to add custom html and css, but it would be ok to have also the default way to make basic html objects/labels/radiobuttons/etc (like in Twitter Bootstrap).
I think, boolean parameters with radiobuttons could be look like these:

And it seems to be ok to add a type of form label for custom parameters like:
Maybe it needs to make a new handler for these inputs to store data depends on element type (e.g. store boolean in json for radiobutton elements).
@tzapu what do you think?
2others: Any ideas? :)
@sooth-sayer commented on GitHub (Aug 7, 2017):
👍
@clooosha commented on GitHub (Aug 7, 2017):
👍
@alevmaltsev commented on GitHub (Aug 7, 2017):
👍
@fundix commented on GitHub (Aug 7, 2017):
👍🏿
Odesláno z iPhone
@teplovoyneytron commented on GitHub (Aug 7, 2017):
👍
@fngstudios commented on GitHub (Aug 8, 2017):
Hi, im using asyncwifimanager now since asynctcp is much faster. I did it really quickly and ugly, I´ll search for the code and post it here. I also found necesary to add an external function call for functions you need to be called periodically while the configuration portal is running. I want to use it becouse I have some nodes with buttons that need to be able to respond even when the wifi is not configured. Im working on make this elegant and readable.
@fngstudios commented on GitHub (Aug 11, 2017):
This is what I did for the bool parameters:
Added the getType method to WiFiManagerParameter and modifyed the constructor:
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length,bool isBoolean) {
.
.
_isBoolean = isBoolean;
.
}
bool WiFiManagerParameter::getType(){
return _isBoolean;
}
Then when you render the parameters:
// add the extra parameters to the form
for (int i = 0; i < _paramsCount; i++) {
if (_params[i] == NULL) {
break;
}
if (!_params[i]->getType()){
String pitem = FPSTR(HTTP_FORM_PARAM);
pitem.replace("{i}", _params[i]->getID());
pitem.replace("{n}", _params[i]->getID());
pitem.replace("{p}", _params[i]->getPlaceholder());
snprintf(parLength, 2, "%d", _params[i]->getValueLength());
pitem.replace("{l}", parLength);
pitem.replace("{v}", _params[i]->getValue());
page += pitem;
}else{
String pitem = FPSTR(HTTP_FORM_BOOL_PARAM);
pitem.replace("{i}", _params[i]->getID());
pitem.replace("{n}", _params[i]->getID());
pitem.replace("{p}", _params[i]->getPlaceholder());
snprintf(parLength, 2, "%d", _params[i]->getValueLength());
pitem.replace("{l}", parLength);
if (_params[i]->getValue()){
pitem.replace("{c}", "checked");
}else{
pitem.replace("{c}", "");
}
page += pitem;
}
}
And in the .h:
const char HTTP_FORM_BOOL_PARAM[] PROGMEM = "
{p}<input type='checkbox' id='{i}' name='{n}' length='{l}' value='1' {c}>";
@tablatronix commented on GitHub (Sep 8, 2017):
How much larger is async ?