Convert String IP to uint32_t

Hi,

just need little bit help in converting String IP which i get from 'server.arg("ip")' to uint32_t, to save it in eeprom..
Here a peace of my script:

struct Settings {
    char url[64];
    char wifiname[64];
    char wifipass[64];
    uint32_t ip;
    uint32_t subnet;
    uint32_t gateway;
    uint32_t dns;    
} sett;

String param_ip;  

if (server.arg("ip") != "") {
    param_ip = server.arg("ip");
    param_ip.toCharArray(ipAddr, param_ip.length());
    Serial.print("PARAM IP: ");
    Serial.println(param_ip);

    IPAddress ipAddr;
    sett.ip = ipAddr;
    Serial.print("SETT IP: ");
    Serial.println(sett.ip);
    
  };

in the Serial Monitor after Saving from WEB i get:

PARAM IP: 192.168.1.250
SETT IP: 0

something failed in conversion from string to uint32_t for IPAddress.
I'm new in C, need help :frowning:

IPAddress ipAddr;
    sett.ip = ipAddr;

Right there

TheMemberFormerlyKnownAsAWOL:

IPAddress ipAddr;

sett.ip = ipAddr;


Right there

That is not really clarifying the issue, but yes there is something missing here. String param_ip; This String is going to hold the IP address in charactersparam_ip.toCharArray(ipAddr, param_ip.length());I am a tad confused that this actually compiles since ipAddr is not yet declared, but if it is as a char* .IPAddress ipAddr;is in fact a 4 byte variable where each byte holds the value of one of parts of the IP address. anyway you will have to manually convert the String to 4 numerical values with the '.'
as a separator. Still sett.ip = ipAddr;is for you address actually the same as sett.ip = (uint32_t) ipAddr[0]<<24 | (uint32_t) ipAddr[1]<<16 | (uint32_t) ipAddr[2]<<8 | (uint32_t) ipAddr[3]; and for your ipaddress would equal 3232236026 (i think i typed it into my calculator..)

if (server.arg("ip") != "") {
  param_ip = server.arg("ip");
  Serial.print("PARAM IP: ");
  Serial.println(param_ip);

  IPAddress ipAddr;
  if (ipAddr.fromString(param_ip)) {
    sett.ip = ipAddr;
  }
  else {
    Serial.println("error: invalid IP address")
  }
}