[GH-ISSUE #1273] Converting Optional String parameter into an IPAddress class variable #1092

Open
opened 2026-02-28 01:28:28 +03:00 by kerem · 9 comments
Owner

Originally created by @bgrigoriu on GitHub (Jul 23, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1273

Hi Everyone,

Had two simple newbie questions.

  1. Does anyone have an example on how to read IP address as custom parameter ( and result in a valid IPAddress class variable).
    I saw that the optionalIPFromString() exists but it is not clear how it works and what checks are done.

  2. Can you do a minimal control of the value of a Custom parameter introduced during startup ? (For example, testing that a serial number fits some minimal criteria and not having to connect to WIFI network then test outside the parameter and restart the process if not appropriate?

Originally created by @bgrigoriu on GitHub (Jul 23, 2021). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1273 Hi Everyone, Had two simple newbie questions. 1. Does anyone have an example on how to read IP address as custom parameter ( and result in a valid IPAddress class variable). I saw that the optionalIPFromString() exists but it is not clear how it works and what checks are done. 2. Can you do a minimal control of the value of a Custom parameter introduced during startup ? (For example, testing that a serial number fits some minimal criteria and not having to connect to WIFI network then test outside the parameter and restart the process if not appropriate?
Author
Owner

@bgrigoriu commented on GitHub (Jul 24, 2021):

Just found the ParamsChildClass example.
Answers part of the question.

<!-- gh-comment-id:886118418 --> @bgrigoriu commented on GitHub (Jul 24, 2021): Just found the ParamsChildClass example. Answers part of the question.
Author
Owner

@tablatronix commented on GitHub (Jul 24, 2021):

I think This was just asked in another issue ipaddress casting

<!-- gh-comment-id:886121829 --> @tablatronix commented on GitHub (Jul 24, 2021): I think This was just asked in another issue ipaddress casting
Author
Owner

@bgrigoriu commented on GitHub (Jul 24, 2021):

Hi, Can you give me the issue# ?
The whole work you all did is just amazing !
Thanks for helping .
Just started learning a few months ago and all the info provided is well received.

<!-- gh-comment-id:886122094 --> @bgrigoriu commented on GitHub (Jul 24, 2021): Hi, Can you give me the issue# ? The whole work you all did is just amazing ! Thanks for helping . Just started learning a few months ago and all the info provided is well received.
Author
Owner

@bgrigoriu commented on GitHub (Jul 24, 2021):

Found some info in the OnDemandConfigPortal. The html checks for format but not for range for the ip.
Need to learn some Html then.

<!-- gh-comment-id:886123261 --> @bgrigoriu commented on GitHub (Jul 24, 2021): Found some info in the OnDemandConfigPortal. The html checks for format but not for range for the ip. Need to learn some Html then.
Author
Owner

@tablatronix commented on GitHub (Jul 24, 2021):

Range? Like you want to verify ip?

<!-- gh-comment-id:886124231 --> @tablatronix commented on GitHub (Jul 24, 2021): Range? Like you want to verify ip?
Author
Owner

@bgrigoriu commented on GitHub (Jul 24, 2021):

yes.
I am trying to build a device for "lay people" and they will need to input an Ip adress and a serial number of a commercial device. So it has to be "....proof". The html code test for format but not for range and you could eventually input 999.999.999.999
No one will ever think to input this but who knows?

<!-- gh-comment-id:886124524 --> @bgrigoriu commented on GitHub (Jul 24, 2021): yes. I am trying to build a device for "lay people" and they will need to input an Ip adress and a serial number of a commercial device. So it has to be "....proof". The html code test for format but not for range and you could eventually input 999.999.999.999 No one will ever think to input this but who knows?
Author
Owner

@bgrigoriu commented on GitHub (Jul 25, 2021):

Just found a solution:
the pattern for defining Ip addresses should not be "pattern='\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'") which allows numbers over 255 but eventually
((^25[0-5])|(^2[0-4][0-9])|(^1[0-9][0-9])|(^[1-9][0-9])|(^[1-9]))\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
OR
((^25[0-5])|(^2[0-4][0-9])|(^1\d{1,2})|(^[1-9]))\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
or alike
Hope helps someone else

<!-- gh-comment-id:886172778 --> @bgrigoriu commented on GitHub (Jul 25, 2021): Just found a solution: the pattern for defining Ip addresses should not be "pattern='\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'") which allows numbers over 255 but eventually ((^25[0-5])|(^2[0-4][0-9])|(^1[0-9][0-9])|(^[1-9][0-9])|(^[1-9]))\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ OR ((^25[0-5])|(^2[0-4][0-9])|(^1\\d{1,2})|(^[1-9]))\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ or alike Hope helps someone else
Author
Owner

@tablatronix commented on GitHub (Jul 25, 2021):

you can use custom regex masks in some browsers for html, or add a js check.

<!-- gh-comment-id:886258532 --> @tablatronix commented on GitHub (Jul 25, 2021): you can use custom regex masks in some browsers for html, or add a js check.
Author
Owner

@bgrigoriu commented on GitHub (Jul 25, 2021):

Ok
Could you please suggest some examples/tutorial/training material/courses ?

<!-- gh-comment-id:886261690 --> @bgrigoriu commented on GitHub (Jul 25, 2021): Ok Could you please suggest some examples/tutorial/training material/courses ?
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#1092
No description provided.