Hello,
I need to notify my Photon incase of an incoming OTA update. My Photon does something critical for 15 secs(not to be interrupted). If there is an OTA update issued within that 15 seconds a flag should be raised to perform the OTA update after the Photon completes it’s critical task(after 15 seconds).
I used the API’s listed in here for this purpose. I did the following:
Disabled the OTA updates using System.disableUpdates()
Checked pending OTA updates using System.updatesPending()
Based on the return value of System.updatesPending(), System.updatesEnabled() is called to perform the OTA.
Observations:
I was printing the return value of System.updatesPending() in the loop() and it’s always 0 even if there is an incoming OTA request from the particle cli.
The particle cli timed out after 30 secs from issuing particle flash myPhoton firmware.bin command
Questions:
Based on the observations:
Why isn’t the return value of System.updatesPending() changing to 1 in spite of an incoming OTA update from the particle cli?
How many retries does the particle flash … … cli command do before timing out?
I’m not entirely sure whether this feature does also apply to developer devices and not only to product devices.
Since OTA update for dev devices is a fire and forget action the cloud might not actually issue the respective event.
But product OTA updates are meant to be defered till a device actually comes online and check for a new binary.
I have a similar question. I have 25 products deployed, they are always connected and never reset. So I added this
if (System.updatesPending())
{
System.reset();
}
which gets run every 15 minutes. The idea is I can release new firmware and have all devices update automatically within 15 minutes or so.
It sort of works, but extremely slowly. In the last 2 hours 2 devices have updated, the rest are showing the update pending in the console. So something isn’t working how I think it should. The 15 minute timing also logs data to a google sheet, so I know that’s working.
I do not believe this System.updatesPending() helper method currently functions for product firmware releases. I will defer to @mdma on this one.
Product firmware updates were built to avoid interrupting a device’s behavior, which is why they are currently only delivered when a device first connects to the cloud. Down the road, I understand completely that there’s a need for more control over when product firmware is delivered.
Whether this control belongs in the firmware or in the cloud is up for debate!
@jeiden, since we still have no solution to ensure a started OTA update will actually prevent a device from interfering with the cloud connection the only way to deal with that is in firmware as it has to refrain from messing up an ongoing update.
I can see this being a critical issue for many of us. As far as I can see, under the current scheme systems that are always connected will never get updated, unless the dev manually goes through every device and forces the update.
Having the firmware being able to see if an update is pending, and decide when to accept it, should be a priority for the Particle dev team , (in my opinion).
were you manually forcing the update, or using the product firmware release system?
I can always force an update, the trouble comes when I want to update all my devices by releasing new firmware - then the system just sits there for ages, waiting for a reconnect from each device, which doesn’t happen since the devices are connected all the time.
This link doesn’t work for me. It opens my IDE (after login in) with the “setup/loop” template. I tried it multiple times. Maybe you could share it on gist (or make the link work) because I’m interested in the code as well.
Just a thought. Have you tried whether this also works non-AUTOMATIC and/or with SYSTEM_THREAD(ENABLED)?
If this in fact does work, I don’t understand why the dedicated System.updatesPending() function is not also capable of the same thing
Thanks @kasper, for the update.
Do you use this on a product device with “defered flash” via console upload or on a development device with immediate upload?