I am attempting to extract an IP address string from a web page set IP address form (working) and overwrite the IP address in the static byte ethernet definition (not working):
Can any one help?
Here is the code so far:
//default
static uint32_t ipA=172;
static uint32_t ipB=31;
static uint32_t ipC=1;
static uint32_t ipD=50;
static byte ip[] = { ipA, ipB, ipC, ipD };
client << F("
") << endl;
client << F("
") << endl;
client << F("Change IP Address:") << endl;
client << F("<form name=\"changeipaddress\" action=\"\" method=\"get\">") << endl;
client << F("<TABLE>") << endl;
client << F("<td>IP Address:</td> ");
client << F("<td style=\"padding-left:10;\"><input type=\"text\" size=\"4\" maxlength=\"3\" name=\"ip1\" value=\"\"></td> ");
client << F("<td><input type=\"text\" size=\"4\" maxlength=\"3\" name=\"ip2\" value=\"\"></td> ");
client << F("<td><input type=\"text\" size=\"4\" maxlength=\"3\" name=\"ip3\" value=\"\"></td> ");
client << F("<td><input type=\"text\" size=\"4\" maxlength=\"3\" name=\"ip4\" value=\"\"></td> ");
client << F("<td colspan=3></td> ");
client << F("</tr> ");
client << F("<tr><td colspan=\"8\"><input type=\"submit\" value=\"Update\"></td></tr> ");
client << F("</TABLE>") << endl;
client << F("</form>") << endl;
client.println("
");
//String stringTEST = "?ip1=172&ip2=31&ip3=1&ip4=50"; //diag example string
String stringTEST = stringOne;
// client.println( stringTEST ); //diag
int firstequal = stringTEST.indexOf('=');
int secondequal = stringTEST.indexOf('=', firstequal + 1);
int thirdequal = stringTEST.indexOf('=', secondequal + 1);
int fourthequal = stringTEST.indexOf('=', thirdequal + 1);
int firstand = stringTEST.indexOf('&');
int secondand = stringTEST.indexOf('&', firstand + 1);
int thirdand = stringTEST.indexOf('&', secondand + 1);
int fourthand = stringTEST.indexOf('H');
client.println("
");
client.println("IP Address Currently Set To:");
client.println("
");
if (stringOne.substring(6,14) == "HIGHTEMP") {
//client.print("Ignore Temperature String in IP Form"); //for diag ignore temperature set string
}
else if (firstequal == -1) {
//client.print("IP Address Not Entered Correctly"); //for diag
}
else {
client.print(stringTEST.substring(firstequal + 1,firstand));
client.println(".");
client.print(stringTEST.substring(secondequal + 1,secondand));
client.println(".");
client.print(stringTEST.substring(thirdequal + 1,thirdand));
client.println(".");
client.println(stringTEST.substring(fourthequal + 1, fourthand - 1));
//MKM Attempt to set IP address octet 4
//stringTEST.substring(fourthequal +1, fourthand -1) = ipD;
//String ipD_String = stringTEST.substring(fourthequal +1, fourthand -1);
client.println("
");
//client.println(ipD_String);
//ipD=57; //compiled with just this line
//ipE=ipD_String; //NO GO
//String ipE = String('ipD_String'); // converting a constant char into a String NO GO
String ipD_string = String( stringTEST.substring(fourthequal +1, fourthand -1) );
int n4_IP;
char carray[6];
ipD_string.toCharArray(carray, sizeof(carray));
n4_IP = atoi(carray);
client.println("
");
client.println(n4_IP);
// static uint32_t ipD=n4_IP; // MKM - caused compile error undefined reference to __cxa_guard_acuire
ipD=n4_IP; //works, ip changes in serial output, but static IP does not change
//ipD = n;
client.println("
");
client.println(ipD);
Serial.println(ipD);
Thanks for your expertise..