Particle.function() with seldom connected device

My Particle Photon is acting as an alarm-clock. The alarm time is set by employing Particle.function, which is called from another computer using curl. This all works well if the Photon is always connected to WiFi + Particle Cloud.
However, it is not. It only connects every 10 minutes. Thus, calling Particle.function fails with an timeout. Obviously, the function call is not stored by the Particle cloud and only issued when the device is online and connected.
So what can I do to talk to my device?

  1. Connect more often? --> Does not work. Even if I connect every two seconds, the function call fails.
  2. Make the Particle cloud call respect the device’s connection state? Well, that is not in my hands. But then, why do I get a "connected": true field in the return message from the function call!?
  3. Use another mechanism to talk to my device? --> Webhooks only work the other way round.

Anybody out there with a good idea? Thanks!

Would it work for your needs to have the computer subscribe to an event that the device publishes when it’s awake? When the computer receives the event, it can then call the function. The function would set the alarm time, and also set a flag that would put the device to sleep.


The question that pops to mind is: “Why does the alarm Photon not stay connected at all time?”

1 Like

Ric, this might be a way. But not easily… I am using either curl or a web-page to set the alarm time and I have little knowledge on how to do this there.
Maybe I should store the alarm time somewhere else (Google drive, Openshift database, …) and then the Photon activly retrieves it.
Thanks for your help!