mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #152] Checkbox to select DHCP or static #118
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#118
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 @Jobenas on GitHub (Apr 12, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/152
Is there any way to include a checkbox in the manager so it is easy to select wether the station connection will be done with dhcp or static ip? I've been reading the documentation but haven't found an easy way of accomplishing this (actually haven't found any way of doing it). Thanks a lot!
Best regards,
Jorge.
@Jobenas commented on GitHub (May 5, 2016):
Hi Tzapu,
I'm posting this on the same thread, hope you can reply :). I managed to place a checkbox on the config portal injecting html code as is shown in the documentation. My first question is how to get the value from the checkbox when I click on save, I tried using the getValue() method but can't get any actual value out of it. The second question is how to make the device connect with DHCP or static? because if I use setSTAStaticIPConfig that automatically forces a static IP to connect, but what if I need to give the choice to the user between the two? I've tried putting that last method in an if, but if the conditional is false, I don't get shown the parameters for IP and connects directly via DHCP. Thanks in advance for any hint you can provide me, and sorry if the post is a bit long.
Jorge.
@tzapu commented on GitHub (May 6, 2016):
jorge, there s no way yet to get a value if you use completly custom html
somewhere on the todo list...
@kentaylor commented on GitHub (May 8, 2016):
There is an example with a check box in the config portal at https://github.com/kentaylor/WiFiManager/blob/master/examples/ConfigOnSwitchFS/ConfigOnSwitchFS.ino . This shows how to get the check box value but doesn't answer your second question.
@josep112 commented on GitHub (Jul 25, 2017):
Has anyone made any progress on this?
@kgreene1983 commented on GitHub (Feb 5, 2018):
This a very useful thread. Ken... Will your code for checkbox work the tzapu version of wifi manager
@Humancell commented on GitHub (Sep 15, 2018):
I saw in the version 0.14 there is a commit that says "adds checkboxes", but I am unable to locate the documentation on this feature. Where is this documented? Just in issues ... and what specifically was added?
@tablatronix commented on GitHub (Sep 16, 2018):
adds checkboxes to the issue template not wm
@ThatchSS commented on GitHub (Dec 19, 2018):
HI All,
thought I'd jump in because I also needed this and found nothing but this thread on the topic.
I think I have a quick fix.??.
I modified the .cpp file to include this but eliminated the no scan as I don't think I'll need it.
I recycled the WiFi (no scan) button to be a WiFi (Static IP) button.
maybe not the most elegant (sorry Tzapu) but definitely the easiest way for me.
then I added this to the following method (just as you see right at the top)
void WiFiManager::handleWifi(boolean statIPAddr) {bool scan = true;if (statIPAddr == true) {IPAddress _ip = IPAddress(10, 0, 1, 50);IPAddress _gw = IPAddress(10, 0, 1, 1);IPAddress _sn = IPAddress(255, 255, 255, 0);setSTAStaticIPConfig(_ip, _gw, _sn);}then I switched the true/false values in the web page handlers
server->on(String(F("/wifi")), std::bind(&WiFiManager::handleWifi, this, false));// switched this and the following T/F valuesserver->on(String(F("/0wifi")), std::bind(&WiFiManager::handleWifi, this, true));don't forget to change the button name in the .h file.
I just have to modify the FS Parameters sketch in the examples to save the values into a SPIFFS/Json file.
so it will reboot correctly after a power cycle.
I hope it is also just as trivial.
I haven't 100% tested it, as its not complete, but just wanted to get it out to you guys, hope it helps.
I'll post the main sketch(.ino) adjustments once I have them, or let me know if you guys figure it out first.
Thanks.
Thatch
@tablatronix commented on GitHub (Dec 19, 2018):
you can add subclasses to parameters in development branch now, there is even an example