Hello
i want assign ip address, netmask address and gateway address to the arduino from user.
- Question :
Can i use reading input like they are getting values from array where user typed the desired values ?
IPAddress ip(IPaddress[4]);
IPAddress subnet(MASKaddress[4]);
IPAddress gateway(GATEaddress[4]);
or like
IPAddress ip(IPaddress[0],IPaddress[1],IPaddress[2],IPaddress[3]);
IPAddress subnet(MASKaddress[0],MASKaddress[1],MASKaddress[2],MASKaddress[3]);
IPAddress gateway(GATEaddress[0],GATEaddress[1],GATEaddress[2],GATEaddress[3]);
- Question :
If i dynamically allocate array in function, how can i assign it to return different arrays to specific inputs ?
Or how to set up that i am setting up array named IPaddress ? Or can i point to globally created array and len the function do its work and then function will return specific array to global array ? how to use that one function to return all three arrays separated ?
how i mean it :
void loop(){
GetAddress(IPaddress[4]);
GetAddress(MASKaddress[4]);
GetAddress(GATEaddress[4]);
Serial.println(ip);
Serial.println(subnet);
Serial.println(gateway);
}
int* GetAddress() {
int *address = (int*)malloc(sizeof(int)*4)
*address = //input of the user, three numbers before "." will be saved here
*(address+1) = //input of the user, three numbers after first "." will be saved here
*(address+2) = //input of the user, three numbers after second "." will be saved here
*(address+3) = //input of the user, three numbers after third "." will be saved here
/* Please, will you will help me with conditions that are in comments too ?
Or just tell me some tips how to write it ? thanks */
//user defined array
//for example : IPaddress[4] = (*address,*(address+1),*(address+2),*(address+3));
//and when it is saved in global array it will delete allocated storage ...
delete GetAddress;
}
can someone help me please ? ask questions if you dont understand and i will try to explain it more better. thanks