Particle.function and sleep modes

Presuming you can’t send a Particle function command to an Electron while it is in one of it’s sleep modes, will the sent commands get queued in Particle cloud until the Electron wakes and re-connects?

The short answer is no. The Particle cloud does not queue Particle function calls.

Thank you @nrobinson2000, what I would like to achieve is; if the Electron is asleep and a command is sent to it to change a variable, next time it connects to the cloud it also receives the changes. What is the best way to do this?

Set up a server that subscribes to an even of your target Electron (e.g. Device came online) and then actively call the function there and then.
Or you have a permanently available server as a home for your variables and the device actively pulls them in.

Thanks @ScruffR I like the latter… I have plenty of questions to follow :stuck_out_tongue:

how to subscribes to an even of your target Electron (e.g. Device came online)?

e.g. via

particle subscribe spark/

This does give me this for any of my devices when I hit reset

subscribing to "spark/" from the firehose (all devices) and my personal stream (my devices)
istening to: /v1/events/spark/
"name":"spark/status","data":"online","ttl":"60","published_at":"2017-03-30T12:43:13.025Z","coreid":"<redacted>"}
"name":"spark/device/last_reset","data":"pin_reset","ttl":"60","published_at":"2017-03-30T12:43:13.237Z","coreid":"<redacted>"}

can I get it through cloud API call?

CLI isn’t doing anything else than hitting the API endpoints, so yes.

@ScruffR @nrobinson2000 If I’m not mistaken, Electron’s can do OTA Flash when they reconnect to the cloud (for example, sending data between sleep events). Would it be possible use that particular event, or one like it, to put the Electron into a “function listen” mode for a short time period to listen for functions coming from the cloud? My idea is that:

  1. Electron is sleeping
  2. Electron wakes up to send some data to cloud
  3. Cloud sends an event back saying you need to go into “function listen” mode for 60 seconds.
  4. Electron waits for 60 seconds while connected to cloud.
  5. Particle.function event sent, Electron does something.
  6. Time expired, going back to sleep & sending data routine.
2 Likes

That’s definetly doable and was (in some way or other) suggested in several threads too :wink:

3 Likes