mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1429] Switching to DHCP mode #1222
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#1222
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 @Alex-Trusk on GitHub (Jun 12, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1429
Hi.
Here is some algorithm (approach) of setting an IP I'm using.
wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn, _gw);WiFiManagerParameter force_DHCP("F_DHCP", "1-Use DHCP 0-StaticIP", "0", 1);wifiManager.setSaveParamsCallback(AfterSaveParamCallback);If IP equals "0.0.0.0" wifimanager would connect to AP using DHCP.
5. After exiting from AfterSaveParamCallback callback wifimanager returns to handlewifisave() function
Is there is another way to connect using DHCP? Can you add another callback that will be called after String ip = server->arg(FPSTR(S_ip));?
@tablatronix commented on GitHub (Jun 13, 2022):
Not sure I understand, dhcp is the default. Are you allowing the user to enter ips?
have you tried just setting ips to
0@Alex-Trusk commented on GitHub (Jun 13, 2022):
Yes, user can enter static IPs.
wifiManager.setShowStaticFields(true);But also I want to give user a choice to set IPs directly or let DHCP server to assign IPs.
I consider two ways to set IP using DHCP.
First. Setting
wifiManager.setShowStaticFields(false);, but user isn't allowed to set IP manually.Second. User is allowed to set IPs manually, but if he wants to use DHCP he have to delete all IPs or set to 0. At least it is not convenient. Using simple radio buttons or checkbox is the easiest way. That’s why I want to check settings in Params Callback function. But _presavecallback() is called just before String ip = server->arg(FPSTR(S_ip)), so I'm unable to make successful IPs manipulations in callback.
I can make changes in wifimanager.cpp by myself and create new callback function. But I want to be sure that there is no other way to let user to switch between dhcp an static IP config.
@tablatronix commented on GitHub (Jun 13, 2022):
Ah ok could do it in javascript. Ill take a look at moving that callback or a way to invalidate ips
@tablatronix commented on GitHub (Jun 17, 2022):
I moved the presaveconfigcallback to after the ips wm vars are set, so maybe now they can be cleared before the wifi connect by clearing the wm _sta_static_ip value
@tablatronix commented on GitHub (Jun 17, 2022):
I also added a presaveparams callback to deal with the new params seperation easier