// String application_command = "{10;12; 4;5; 2}";
// String application_command = "10;12; 4;5; 2";
String application_command = "ST=10:12:0";
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length()-1;
for(int i=0; i<=maxIndex && found<=index; i++){
if(data.charAt(i)==separator || i==maxIndex){
found++;
strIndex[0] = strIndex[1]+1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}
void setup() {
Serial.begin(9600);
String firstPart = getValue(application_command,':',0);
Serial.println(firstPart);
}
void loop() {
// put your main code here, to run repeatedly:
}
// String cmd = "r3=+639309096290";
// void setup(){
// Serial.begin(9600);
// Serial.println(cmd.indexOf("r3=") > -1 );
// }
// void loop(){
// }