Product did not update the firmware

Hi,

I uploaded a new firmware into my product page. This product only has one device (by the moment)

The problem is that I assigned the firmware and locked but the device still not updated 18hours after.

The device wakeup every 15mins and after sending the info, sleeps again.

I’m doing something wrong? the script wakeup in semiautomatic mode, and when the info is prepared, the machine connects to particle and sends, could be this the problem?

Thank’s

Eduard

The device needs some time after reconnect to realise there is an update pending and then a further few moments to actually download and flash the new firmware.
If you are going back to sleep too quickly the update will never stick.

Hi @ScruffR

So, what I should I do? put a Delay when all the jobs has done? how do I do this “time” to Electron update?

This is part of the script connection

Particle.connect();
                if (waitFor(Particle.connected, 300000 ))
                    { // proceed only if a connection could be established

Thank you very much

Could you show the complete code, or at the very least the part where it goes to sleep?

Sure,

These are the highlights

STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
SYSTEM_MODE(SEMI_AUTOMATIC)
SYSTEM_THREAD(ENABLED)    
.
.
.
void loop() {
.
.
.
float wstempC = getAndResetTempF();
                float wshumidityRH = getAndResetHumidityRH();
                float wspressureHPa = getAndResetPressurePascals() / 100.0;
.
.
.
Particle.connect();
                if (waitFor(Particle.connected, 300000 ))
                    { // proceede only if a connection could be established within 60 seconds 
                    //Building JSON
                    String dest = "{";
                    if(Svtime.length() !=0){ dest = dest + "\"1\":\""+ "1" +"\",";}
                    if(Svtime.length() !=0){ dest = dest + "\"2\":\""+ Svtime +"\",";}
                    if(Stemp.length() !=0){ dest = dest + "\"5\":\""+ Stemp +"\",";}
                    dest = dest + "}";
                    
                    Particle.publish("XXXXXXX",dest ,60,PRIVATE);

                       // Schedule the next publish event
                    vtimeNextPublish = millis() + publishPeriod;
                    }
                    delay(10);
        
                   }
..
.
.
.
        **System.sleep(SLEEP_MODE_DEEP, sleepPeriode, SLEEP_NETWORK_STANDBY); //Sleep a while to save battery    **
**    }**

Thank’s

After connecting, and before going to sleep, there’s virtually no time to even notice there’s updated firmware, let alone download/flash it. Try giving it a bigger delay?

@ecabanas,

You could consider a once-a-day delay event that waits at least a minute or two before going to sleep.

pseudo:

uint32_t tsYearStart = makeTimeStamp(1, 1, Time.year());
uint32_t tsNow = Time.now();
int dayOfYear = (tsNow - tsYearStart) / SECONDS_PER_DAY;
if (dayOfYear != retainedDayOfYear)
{
  uint32_t startProgramWindowMillis = millis();
  while (millis() - startProgramWindowMillis < PROGRAMMING_WINDOW) 
    Particle.process();
  retainedDayOfYear = dayOfYear;
}
2 Likes

That's actually a very elegant solution! I actually run my while loop with particle.process() every time the Electron wakes up (which eats up battery). Having it just do that once a day is really clever. Cheers!

1 Like

Hi,

The solution what I did is the following:

if ((Time.hour() >= 11) && (Time.hour() < 12) && (Time.minute()>= 0) && (Time.minute()  <= 10))
            {
            Particle.Connect();
            delay(180000);  //wait to sincronize 3 minutes
            
            }
            else {
 .
.
.
            }

The machine connects to Particle and waits 3 minutes every day at 11 between 00 and 20 minutes.

Thanks Eduard! That indeed does work but I found through experimentation that you don’t need more than 30 seconds to trigger the update; that’s good to know if you’re trying to conserve battery.

Hi Ahmed_Spero

Thank’s for your advice, I’m going to put 3 minutes and see what’s happen. If I could to update the machine, I’m going to reduce this delay.

Thank’s

Eduard

is that right?

break it down:
if( hour == 11 and minute <=10 and minute >=0) // restated

that expression can be true for 11 minutes.

Remember also, giving opportunity for more than one prolonged wake-up event. during that time (actually four).

Hi

My machine wakes up every 15 mins, so when the machine wakes up between this time the machine waits to be updated, when wakes up out of range the machine does the normal reading and sending

Then you run the risk of missing that window completely

Hi,

No, because I did a mistake, the maximum is 20 and min is 0 minutes.

1 Like