[GH-ISSUE #957] Question: Use of Static IP #813

Closed
opened 2026-02-28 01:27:09 +03:00 by kerem · 3 comments
Owner

Originally created by @lbussy on GitHub (Oct 22, 2019).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/957

Working in the development branch:

I found a reference (in a comment) in the script referring to using a static IP, and I also dug in the source code a bit:

github.com/tzapu/WiFiManager@9a85b107fa/examples/Advanced/Advanced.ino (L52)

Am I correct in my understanding that to use this it should get set before calling wm.autoConnect(ssid, pwd); and that doing so will auto-connect to the configured access point with that IP information instead of using WiFi.config(ip, gw, sn, dns);?

I also saw:

wm.setShowStaticFields(true); // force show static ip fields
wm.setShowDnsFields(true);    // force show dns field always

The implication there is I don't have to set up custom fields to configure static IP and DNS (yay!). What's not clear is whether those fields autosave anywhere or if I need to save them manually. If the latter, how do I access the field values to save? If they are auto-saved, how do I access them initially to set the setSTAStaticIPConfig() call?

I looked through all the rest of the examples as well as chased it a bit through the source code but did not find my answer. The core documentation was likewise not helpful. I got as far as ESP8266WiFiGenericClass::persistent() and then got lost. Hopefully I didn't miss an obvious answer to this.

Originally created by @lbussy on GitHub (Oct 22, 2019). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/957 Working in the development branch: I found a reference (in a comment) in the script referring to using a static IP, and I also dug in the source code a bit: https://github.com/tzapu/WiFiManager/blob/9a85b107fa264a5a3e2218f72b18dfab629b1260/examples/Advanced/Advanced.ino#L52 Am I correct in my understanding that to use this it should get set before calling `wm.autoConnect(ssid, pwd);` and that doing so will auto-connect to the configured access point with that IP information instead of using WiFi.config(ip, gw, sn, dns);? I also saw: ``` wm.setShowStaticFields(true); // force show static ip fields wm.setShowDnsFields(true); // force show dns field always ``` The implication there is I don't have to set up custom fields to configure static IP and DNS (yay!). What's not clear is whether those fields autosave anywhere or if I need to save them manually. If the latter, how do I access the field values to save? If they are auto-saved, how do I access them initially to set the setSTAStaticIPConfig() call? I looked through all the rest of the examples as well as chased it a bit through the source code but did not find my answer. The core documentation was likewise not helpful. I got as far as ESP8266WiFiGenericClass::persistent() and then got lost. Hopefully I didn't miss an obvious answer to this.
kerem 2026-02-28 01:27:09 +03:00
Author
Owner

@lbussy commented on GitHub (Oct 23, 2019):

"Seems like" that's how it works - that setShowStaticFields(true) will allow setting a static IP and that setShowDnsFields(true) allows setting a DNS server. Further, somehow, ESP8266WiFiGenericClass::persistent() saves that off automagically. It seems like there's no need to use setSTAStaticIPConfig() when this is done.

Hopefully, that's correct. It seems to work anyway.

<!-- gh-comment-id:545210267 --> @lbussy commented on GitHub (Oct 23, 2019): "Seems like" that's how it works - that `setShowStaticFields(true)` will allow setting a static IP and that `setShowDnsFields(true)` allows setting a DNS server. Further, somehow, `ESP8266WiFiGenericClass::persistent()` saves that off automagically. It seems like there's no need to use `setSTAStaticIPConfig()` when this is done. Hopefully, that's correct. It seems to work anyway.
Author
Owner

@tablatronix commented on GitHub (Jun 13, 2021):

The esp will not remember static or ip info you will have to save it and restore it

<!-- gh-comment-id:860274088 --> @tablatronix commented on GitHub (Jun 13, 2021): The esp will not remember static or ip info you will have to save it and restore it
Author
Owner

@lbussy commented on GitHub (Jun 13, 2021):

Understood, thanks. I was just cleaning up an old issue.

<!-- gh-comment-id:860274220 --> @lbussy commented on GitHub (Jun 13, 2021): Understood, thanks. I was just cleaning up an old issue.
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#813
No description provided.