Particle variables implemented with a function call

I’d like to tell my device, from the cloud, “give me a full status report”. This would include things like all the values of attached sensors, actuators, internal application state and so forth. Useful for debugging and problem analysis for a device deployed to a customer.

It would be nice if this was a synchronous RPC-style call, not an asynchronous event: that makes test / debug setups much simpler.

Particle variables seem perfect … except that I don’t know when the firmware is about to read my variable, so I would have to pre-compute my status report. But I can’t do that because such a full status report is fairly expensive, and rarely, if ever, asked for.

So. Unless something like it exists already, I’d like to ask for a

Particle.variable( varName, functionPointer )

method in the firmware, where the firmware invokes my functionPointer when it wants to read the variable, and I return the value of the variable in its return value.

P.S. How does one best make suggestions for how to improve the product?

Unless I’m really mistaken, function calls can already (and should) return a value.
Alternatively, you could make a function to trigger all readings (e.g. create the report), which could then be read from a Particle.variable. A variation of that would be a function call that ‘makes’ the report, and then publishes it using Particle.publish.

As to suggestions for improvements, the forums are a great place to discuss and work out some ideas. Once you’ve got a solid ‘plan’, github is the place to be.

1 Like

Functions apparently can only return an integer value, so that would pose a report compression challenge :smile:

Yes, I’m planning to implement exactly your workaround.