Pass multiple arguments to photon function

How can I pass multiple argument to my photon function?

As one arguments, after which you parse those within the function. Here’s an example I’ve taken from the “messagetorch”, which takes parameters as “key1=value1,key2=value2” etc. Give it a shot :smile:

int handleParams(String command)
{
  //look for the matching argument <-- max of 64 characters long
  int p = 0;
  
  while (p<(int)command.length()) {
    int i = command.indexOf(',',p);
    if (i<0) i = command.length();
    int j = command.indexOf('=',p);
    if (j<0) break;
    String key = command.substring(p,j).toUpperCase();
    String value = command.substring(j+1,i);
    int val = value.toInt();
    
    if (key=="FADE"){
        fade = val;
    }
    else if (key=="R") {             
    }
    else if (key=="G"){             
    }
    else if (key=="B"){             
    }

    p = i+1;
  }
  return 1;
}
1 Like

Here is another example on the forum:

2 Likes