Installing update from a sketch

I’m hopeful this is just me misreading the documentation, but I’ll ask anyway. Google and searching this forum haven’t showed me an answer.

Basically, I want to check for an update and install it when I turn on WiFi. The Photon is mostly asleep, waking up for a few hours to run an LED program. To save battery, it turns off WiFi for 99% of the runtime. Every hour, it turns on WiFi, checks to see if it should change the LED program via a quick TCP socket call to a local server, and then turns it back off and goes back to running the program.

What I would like to do is when it wakes up from sleep, check if there is an update available and apply it. I know about the updatesPending API, but I don’t know how to push an update to the cloud so that it sits waiting for the device to check in. The curl + REST api for uploading a precompiled binary returns failure if the device isn’t listening. I’ve never tried to see if it’s just sitting waiting for the device to check in though. However, I suspect it doesn’t based on the return value. Ideally, I’d queue this update locally and install it from my own server, but I assume that isn’t possible.

So, what REST API can I use to upload a binary to be installed when the device checks in, and do I need to do anything special to get it to install at that time?

If I understand your intent correctly, this might be for you
https://docs.particle.io/reference/api/#flash-a-device-with-a-pre-compiled-binary

I have that already. I use makefiles in Eclipse to send my build to my target using curl + REST, but it only works if the device is online and ready. I want to send an update at any time to the cloud and then when the device wakes up, it asks for an update if available. There isn’t an API to queue an update for later that I can distinguish, and a very limited test didn’t queue one up for me when I tried that REST API on a device that wasn’t online. So, how can I put a new binary into a location that can be queried the next time the device wakes up from sleep?

@peteb, deferred OTA is not yet implemented but it is in the works. You can, however, have your server subscribe to the online event published when the device comes online at which point you would send the update if one is pending. :smile:

1 Like

Reading that I thought you could use a Particle.publish() from your waking device to trigger a webhook (or just listen to the “came online” event) on your server to start the upload via that API endpoint …
(as @peekay123 just wrote that same moment)
… since this is not yet implemented for developers.
Or if you are a product creator with a organization dashboard subscription it’s already there for you.

The webhook mechanism might work. I’ll look into that. Thanks.

Do we know what release deferred OTA is targeted to?

no ETA yet