Search code examples
c++stringarduinochartcpclient

Arduino, to receive data from client and put the chars, of data, in three different string


In Arduino i have this code:

 WiFiClient client = server.available();
     if (!client) {
        return;
      }
    while (client.available()){
    char d = (char)client.read();
    // In this part save to the string
    }

i recive this string:

true,167*FFFFD19F/

i want put the character into a three different string, as:

String1 = "true"
String2 = "167"
String3 = "FFFFD19F"

Solution

  • Thank you I have found the solution:

    while (client.available()) { 
       delay(3);
       char c = client.read();
       readString += c;
    } 
    readString.trim();
    int i1 = readString.indexOf(",");
    int i2 = readString.indexOf("*");
    int i3 = readString.indexOf("/");
    String 1= readString.substring(0, i1--);
    String 2= readString.substring(i1 + 2, i2); 
    String 3= readString.substring(i2 + 3, i3--);