Electron 0.5.2 System.updatesPending()

Just clear logic of System.updatesPending()
I am in DEEP_SLEEP (SEMI_AUTO) wake up then connect to cloud. Check if System.updatesPending() return true not going in deep sleep.

  1. It is mean that we have new firmware in cloud? (even if i try to download from web build with OTA during deep sleep)
  2. As soon firmware will be updated (in witch moment it is start update … as soon we connect cloud or else?) we not get this System.updatesPending() true anymore?

We need better docs for that so i filed an issue:

1 Like


is there any update or short example which shows how we can use System.updatesPending() with deep sleep?

Kind regards,

Still no… look like it is not implemented till from Cloud side. (in my mine must work like we make OTA update and it is must update firmware as soon as device wake up from deep sleep, but it is not working for now)

AFAIK, this is already working for product devices via the Particle Console which now everybody can try out for free.

It is mean when we use particle flash deviceName my_project (from command line) Electron wakeup from deep sleep and automaticly flashing new firmware? (not going back to deepsleep till not flashing new one)
Or it is just set System.updatesPending() and we need to doing somethink in our software for flashing?

particle flash ... is a “there-and-then” action. If the device is online it will get the notification (and update if it’s not blocked) otherwise that action will timeout.
The Console OTA update works slightly different. You upload your binary to the Console servers and they will wait for your device to come online and will there-and-then trigger the upload for you.

System.updatePending() is just there to give you the choice and means to prepare for an update or not.

OK Thanks… will check OTA from build.particle.io … just push OTA falsh OK and wait till next wake up. It is correct?

https://build.particle.io is not the same as https://console.particle.io/products

With Build that won’t work.

Is there some Tutorial with screen shots? What i have to press and enter in Products tab?

Thank you very much for the clarification :smile:
My Photon is sleeping for about 10 minutes, then it wakes up, takes some measurements and sends them to my server and stays online for a few more seconds to make sure everything did go well.
So in my case I would do the following:

  • after wakeup check if there is an update pending
  • if yes, disable OTA updates, take measurements, send them to my server
  • in the few seconds after sending the data to the server and before going to sleep again enable OTA updates

My Photon is online for about 4 seconds after the publish. Will the update start during that time?
I would say my Photon got the notification of an update after waking up from sleep so it just waits for System.enableUpdates() to start with the OTA.

Kind regards

Usually when your device was notified of an update you need to actively stay awake longer than 4sec - more like 30~60sec.
An OTA flash will not stop your code from running during the download phase, so if you send your device back to sleep your OTA will fail.

1 Like

This code not working… i have fail flash message from cloud Why?

        if (ReadyToSleep == 1 &&  System.updatesPending() == false)
	     index = 0;
	     EEPROM.put(0, index);   
 	     Serial.println("Go to sleep!");

//if (index < 48)  {delay(5000);	   mesuring_done = 0;}
if (index < 48)  {Cellular.off();System.sleep(SLEEP_MODE_DEEP, 5);}

What should this do and how is it not working?
Don’t save your time by letting us do the guessing!

if we send firmware over product tab then System.updatesPending() must be true till firmware not updated?

When it is update board must restart automaticly?