referring to pins via its name for RPC

13 May 2011

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);
    
}
13 May 2011

I don't think I made it clear, what I want to achieve is loop through the supplied pinNames and return their values in a formatted string.

EG.

Enter "HTTP://mbedip/rpc/returnRPC/run led1,p12,led3" in my browser and it returns

"1,0,0"