if (strcmp(command, "set ip") == 0) { //Set Low Temperature Limit (where compressor will go OFF)
byte ip[4];
ptr = strtok (parameter, "."); // look for first .
ip[0] = atoi(ptr);
for (int i=1; i<4; i++){
ptr = strtok (NULL, "."); // look for .
ip[i] = atoi(ptr);
}
//byte ip[4] = { ip_A, ip_B, ip_C, ip_D };
Serial.println("IP set to: " + parameter);
NetEeprom.writeIPConfig(ip);
Serial.print(F(">"));
Serial.flush();
}
if (strcmp(command, "set subnet") == 0) { //Set Low Temperature Limit (where compressor will go OFF)
byte ip[4];
ptr = strtok (parameter, "."); // look for first .
ip[0] = atoi(ptr);
for (int i=1; i<4; i++){
ptr = strtok (NULL, "."); // look for .
ip[i] = atoi(ptr);
}
//byte ip[4] = { ip_A, ip_B, ip_C, ip_D };
Serial.println("Subnet set to: " + parameter);
NetEeprom.writeSubnetConfig(ip);
Serial.print(F(">"));
Serial.flush();
}
if (strcmp(command, "set gateway") == 0) { //Set Low Temperature Limit (where compressor will go OFF)
byte ip[4];
ptr = strtok (parameter, "."); // look for first .
ip[0] = atoi(ptr);
for (int i=1; i<4; i++){
ptr = strtok (NULL, "."); // look for .
ip[i] = atoi(ptr);
}
//byte ip[4] = { ip_A, ip_B, ip_C, ip_D };
Serial.println("Gateway set to: " + parameter);
NetEeprom.writeGWConfig(ip);
Serial.print(F(">"));
Serial.flush();
}
if (strcmp(command, "set dns") == 0) { //Set Low Temperature Limit (where compressor will go OFF)
byte ip[4];
ptr = strtok (parameter, "."); // look for first .
ip[0] = atoi(ptr);
for (int i=1; i<4; i++){
ptr = strtok (NULL, "."); // look for .
ip[i] = atoi(ptr);
}
//byte ip[4] = { ip_A, ip_B, ip_C, ip_D };
Serial.println("DNS set to: " + parameter);
NetEeprom.writeDNSConfig(ip);
Serial.print(F(">"));
Serial.flush();
}
and the serial parser is:
//Serial parser
void serialParser(void) {
//
// One command per line. Eventually, Data may have multiple
// fields separated by ":"
// Command Format: "up to 5 Letter command, up to 10 letter data<\n>"
// No checking.
//
// count will be below Zero on a timeout.
// read up to X chars or until EOT - in this case "\n"
byteCount = -1;
byteCount = Serial.readBytesUntil('\n',strRS232_rx,RS232buffSize);
delay(5);
if (byteCount > 0) {
strcpy(command,strtok(strRS232_rx,"="));
strcpy(parameter,strtok(NULL,","));
}
memset(strRS232_rx, 0, sizeof(strRS232_rx)); // Clear contents of Buffer
Serial.flush();
}
at this stage, the parameter is holding the sub string containing IP or any other info. Now, I think that should work...
Serial.println("IP set to: " + ip[0] + "." + ip[1] "." + ip[2] "." + ip[3]);
Ok, apart from that, also another question, do I have to worry about RAM and stack and Heap?? For a prolonged operation??
[though this commands are for config mode only, will run for specific time of a life, and after which it needs reboot to take the new config in active.]