Good afternoon
I'm trying to return more than one value at once via RPC.
I have the function set up to return the values I now need to get the value of the requested pin or function and send it back.
This code sets up the RPC function then defines it below. I loop through the sepparated strings and want to then return the value of the named pin etc.
EG. with the HTTP RPC service if I do
"http://mbedip//rpc/returnRPC/run this,is,a,test"
I want it to return the values for pins named this, is, a and test
//Example code not actually in the working version, just for demo purposes
DigitalIn this(p19,"this");
DigitalIn is(p20,"is");
DigitalIn a(p21,"a");
DigitalIn test(p22,"test");
void returnRPC(char * input, char * output);
RPCFunction rpcreturnRPC(&returnRPC,"returnRPC");
void returnRPC(char * input, char * output){
char out[255] = "";
char delims[] = ",";
char *result = NULL;
result = strtok(input, delims);
while ( result != NULL ) {
strcat(out,result); // Append the results for test purposes.
result = strtok ( NULL, delims );
}
sprintf(output, "%s", out);
}
Good afternoon
I'm trying to return more than one value at once via RPC.
I have the function set up to return the values I now need to get the value of the requested pin or function and send it back.
This code sets up the RPC function then defines it below. I loop through the sepparated strings and want to then return the value of the named pin etc.
EG. with the HTTP RPC service if I do
"http://mbedip//rpc/returnRPC/run this,is,a,test"
I want it to return the values for pins named this, is, a and test