Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adde methods to se if static IP addresses were configured, and what those addresses are #1720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonasbjurel
Copy link

To be able to find out if the network with static addresses or with DHCP following methods are proposed:

//check if static network configuration is set
bool          isStaticIp(void);

//provides static host ip address provided method isStaticIp() returns true
void          getStaticIp(IPAddress* staticIp);

//provides static gateway ip address provided method isStaticIp() returns true
void          getStaticGw(IPAddress* staticGw);

//provides static network mask provided method isStaticIp() returns true
void          getStaticSn(IPAddress* staticSn);

//provides static DNS ip address provided method isStaticIp() returns true
void          getStaticDns(IPAddress* staticDns);

those addresses are:
    //check if static network configuration is set
    bool          isStaticIp(void);

    //provides static host ip address provided method isStaticIp() returns true
    void          getStaticIp(IPAddress* staticIp);

    //provides static gateway ip address provided method isStaticIp() returns true
    void          getStaticGw(IPAddress* staticGw);

    //provides static network mask provided method isStaticIp() returns true
    void          getStaticSn(IPAddress* staticSn);

    //provides static DNS ip address provided method isStaticIp() returns true
    void          getStaticDns(IPAddress* staticDns);
@ntechnix
Copy link

Do you have any plans to update it to a product that supports static IP settings?

@tablatronix
Copy link
Collaborator

This is all stuff you can do in code already

@jonasbjurel
Copy link
Author

This is all stuff you can do in code already

Could you just give a hint on how?
For instance understand if the addresses where provided as static addresses in the wifi-manager, or if it was provided by the DHCP server?

@jonasbjurel
Copy link
Author

A small codesnip:
if (networkConfig.staticIp = wifiManager.isStaticIp()) { wifiManager.getStaticIp(&networkConfig.ipAddr); wifiManager.getStaticSn(&networkConfig.ipMask); wifiManager.getStaticGw(&networkConfig.gatewayIpAddr); wifiManager.getStaticDns(&networkConfig.dnsIpAddr); } else { networkConfig.ipAddr = WiFi.localIP(); networkConfig.ipMask = WiFi.subnetMask(); networkConfig.gatewayIpAddr = WiFi.gatewayIP(); networkConfig.dnsIpAddr = WiFi.dnsIP(); }

@tablatronix
Copy link
Collaborator

Static configs are not stored in flash, so user code has to store and recall them. So no need for wm specific wrappers

@jonasbjurel
Copy link
Author

Static configs are not stored in flash, so user code has to store and recall them. So no need for wm specific wrappers

That is exactly why I want to know where to fetch the config, I.e. using: bool isStaticIp(void);
I guess my small additions does not break anything, and I got my code working with these additions, which I failed to without them.
BR/J

@tablatronix
Copy link
Collaborator

I am assuming this only works right after you save wifi ?

@jonasbjurel
Copy link
Author

I am assuming this only works right after you save wifi ?

Correct, after having saved WiFi, I use these method to check if a static address was configured, and if so I fetch the static addresses using these methods, if not static I fetch the DHCP assigned addresses using the normal WiFi methods.
BR/Jonas

@jonasbjurel
Copy link
Author

Hi again, what is the status, will my proposed changes be merged?
I'm approaching a release of one of my projects which rely on WiFi manager, if these changes are not merged I'm afraid I need to maintain a fork of the WiFi manager.
Regards /Jonas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants