Hi,
Oh wait a minute… yes this is indeed what I am doing - as I publish the results back to the cloud (from getdata) :-O. BUT I don’t see why this should result in the following weird behaviour though :-O.
I actually have two functions exposed in my photon, both expecting a string - called getdata and setdata.
I have a windows Form app (in C#)…
I call getdata with (lets say) ‘blk=3’. It works perfectly as expected and returns the published data as requested. Call it again and again (blk=4, blk=5 etc.) and it works as expected.
If I call setdata (separate function) with less than 63 chars data - it now works, gets the command string and does its thing ;-)) - it does NOT publish data back.
BUT lets say I call getdata blk=4 and get the result. THEN call setdata with > 63 chars of data, the string passed in to setdata is ‘blk=4’ - ie the previous string sent to my photon :-O.
I have checked (and double-checked) the C#, right up to sending the call and my postdata definitely does NOT contain blk=4 :-O.
The photon functions are separate and don’t share the data
Spark.function("getdata",&FRAM::readData, this);
Spark.function("setdata",&FRAM::writeData, this);
int FRAM::readData(String command)
{
int resp = 1;
char inputStr[100];
char txt[10];
int blk = 0;
int i;
Serial.print(command);
Serial.printf("\r\nreadData: %s\r\n", command.c_str());
command.toCharArray(inputStr, 100);
etc.....
DOES end in a publish !!!!
int FRAM::writeData(String wrcommand)
{
int resp = 1;
char inputStr[100];
char txt[10];
int blk = 0;
int i;
Serial.println(wrcommand);
Serial.printf("\r\nwriteData: %s", wrcommand.c_str());
etc...
Its not a major problem - as I now ensure that I send in less than 63 chars. All that means is that to write a 32 byte block of data - I need to send two separate setdata function calls.
It just confused the HE*L out of me to start with - when I was trying to send too many chars ;-)).
NB I think that if I called twice consecutively with too much data - it passed nothing in the second time (which is not unreasonable ;-)). I only noticed the anomalous behaviour by sending a GOOD (getdata) command in between (which of course DOES do a publish ;-)).
Please accept my apologies if this is NOT a bug and that I am doing something stupid ;-)) - not unheard of !!!
I suspect it IS a bug though - that something is not being cleared when bad data is received ;-)).
BR
Graham