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.
- 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
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?
- How do I get this to work?
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.
@jeiden might be able to clarify thart tho’
I have a similar question. I have 25 products deployed, they are always connected and never reset. So I added this
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.
Is this the best way to trigger the update?
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.
@dheerajdake, a background check with Particle has revealed that
System.updatesPending() actually currently is of no use.
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).
Try this example that listens to the
firmware_update_pending system event:
your link takes me to my own IDE page, not your code.
Can you click on the link again: https://go.particle.io/shared_apps/58e435e99011dc0b4f00123f
It should show:
You will be able to view the code and even copy it. Let me know if it doesn’t work. I can share it elsewhere.
OK seems to work now, dont know what happened before.
Question: does this only work at startup? Because I need it to be able to detect pending updates when running the main code.
I used it in the project that runs 8 hours a day for 3 months straight and have always been able to OTA new updates whenever required.
Not sure if that answers your question.
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.
I’ll check and get back to you
@twospoons, it’s on the roadmap but as of now, the device needs to reconnect before ota of new firmware version occurs.
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
If this in fact does work, I don’t understand why the dedicated
System.updatesPending() function is not also capable of the same thing
I use both MANUAL and SYSTEM_THREAD and this code works fine. However it could be nice if
System.updatesPending() can do this job as well.
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?