From particle console I’m verifying that “selection” get called .
Also from the debug tab, from Rule engine, it can be seen that the function get called from the cloud( Rule engine), cause -1 is the value returned as payload.
The strings arguments are being sending as can be seen on the R. engine debug tab.
I should received printed out on terminals the numbers 1, 2 and 3 when the selection of RF1, RF2 and RF3 are chosen respectively, but does not happen.
Can I get some help on that?
I did manage to get the function return value back into the Rules Engine, but I found another quirk that feels like a show stopper for function calls - I’ll get to the bottom of it tho’
Just one note on your dropdown node: If you set the string value (left input box) to 1, 2 and 3 instead of RF1, RF2 & RF3 and only keep the long labels, you wouldn’t need to do the string comparison inside your Particle.function() handler but could just use command.toInt().
I’m also not sure why your return values are always one less than the value you send in and store in refr.
With both these changes your function handler would simply look like this
int selection (String command) {
int retVal = command.toInt();
if (1 <= retVal && retVal <= 3)
Serial1.println(refr = retVal);
else
retVal = -1;
return retVal;
}
Thank you again.
Those weird return values were just for debugging.
Anyway the code you proposed me is more coherent regarding
the conversion form string to int though the particle.function node keeps
returning -1.
The console return the corrects values… 1, 2,3 .
I’d consult to @rickkas7 also.
Regards,
I was told that there is a bug in the outbound Particle nodes where they only ever send the first argument they receive after deployment.
So currently the Particle nodes (apart from Subscribe) are rather useless for meaningful work with dynamic data.
You can get around this via a standard function node containing this code
From particle console I’m verifying that “selection” get called .
Also from the debug tab, from Rule engine, it can be seen that the function get called from the cloud( Rule engine), cause -1 is the value returned as payload.
I should received printed out on the terminal the numbers 1, 2 and 3 when the selection of RF1, RF2 and RF3 are chosen respectively, but does not happen.
Can I get some help on that?
I moved this re-post here since double posting is not appreciated.
You did tag Rick already in your earlier post here so there is no need to open a new thread which would merely scatter the discussion over multiple threads.
BTW, have you seen my proposal for a workaround above?