Arduino Function: splitString


The splitString function enables the user to manage the MCU command sent by the connector. The function accepts up four parameters, the first is the serial command for the MCU, the second parameter is the character that should be used to split the serial command, while the third and fourth parameter are respectively, the array of strings used to split the serial command received and the size of the array itself .


If by a xmpp connector send a command with three parameter, like "digital/13/1", to split the command will need to create a three element string array and after invoke the splitString function


void setup() {
void loop() {
                 CiaoData data ="xmpp");
                 String id = data.get(0);
                 String sender = data.get(1);
                 String message = data.get(2);
                 String command[3];
                 Serial.println("command type: "+command[0])
                 //output is digital Serial.println("pin: "+command[1])
                 //output is 13 Serial.println("pin value: "+command[2]))
                 //output is 1

Written by