Mark,
For the RPC to return something back in the HTTPServer, you need to make your function return that value. If that is a string, you need to return char*. See myrpc::echo() in my example pub_iva2k_ethsntp. - echo takes in a string and returns it back, so http call will be:
http://my_mbed_ip/rpc/myrpc1/echo+"Some string to be echoed back"
Note that in my example I changed HTTPRPC.h to handle quoted strings in the URI.
Perhaps you know that, but another thing to note is that returning char* can be tricky - you have to allocate a buffer somehow to make it stay after function returns (if you juct return a local char[] variable, it won't work since it is allocated on stack and deleted upon function return). There are many ways to do it properly, but it is easy to create a memory leak if care is not taken.
Here's a quick fix using statically allocated buffer (I mis-indented my additions to illustrate the changes):
char * myrpc::readGyro(int cycles) {
char cmd[2];
static char buffer[1024]; // use static keyword to make the buffer persist after function returns
const int add2 = 0xA4;
buffer[0] = 0; // init it to an empty string
for (int i=0; i<cycles; i++) {
int yaw, pitch, roll;
cmd[0] = 0x00;
i2c.write(add2,cmd,1);
wait(0.01);
char data[6];
i2c.read(add2,data,6);
wait(0.01);
yaw = (data[3] - 131);
pitch = (data[5] - 130);
roll = (data[4] - 126);
sprintf(buffer,"Yaw:%d Pitch:%d Roll:%d\n",yaw,pitch,roll);
}
return buffer;
}
Of course you have to also change the RPC wrapper to use char* return type.
I am developing a project which includes 18 mbed mcu's which I'd prefer to connect via ethernet. The mbeds and a couple PCs will all share data from various sensors, etc.. via this connection. The network will be private, and have no DHCP, DNS or internet connection. I plan on using hard coded IP addresses for each device.
Can anyone suggest a protocol or whatever suported by the mbed to use for this communication? I'd prefer not to use http. I'd prefer two way comms between whichever device decides it needs to share something with another device on the network. It could be #4 telling #12 something one time, or #8 telling #4 something another, or at the same time...
Any input is welcome, and I appreciate all comments or ideas!!
Thanks
-mark