Issues with FW OTA update

Hi guys,

I am trying to update my firmware using the Particle console.

I upload my new FW on the console, and when my devices wakes up, it calls this API:

void otaHandler()
{
 if(System.updatesPending());
 {
     // add a flag
     FWupdate=true; 
     Log.trace("updates pending");
 }

I verified that indeed upon system wakeup from sleep, the FWupdate flag becomes true. However, I don’t see that my firmware gets update.

As soon as the this flag is set I call the below APIs:

System.enableUpdates()
delay(120000);
System.reset();

Could anybody comment what I might be missing that makes my system fails updating upon system wakeup.

Thank you all in advance.

@Andre, you may want to try to use a non-blocking delay to replace delay(120000) with:

for(uint32_t t = millis(); millis() - t < 120000L; Particle.process());

This will allow the DeviceOS to get serviced during the pause.

Thank you for your comment!

I actually tried what you suggest by adding the for loop for delay but I have not seen any updates taking place:

function()
{
    Log.trace("This OTA state before updates are enabled");

    System.enableUpdates();

    Log.trace("This OTA state after updates are enabled");

    for(uint32_t t = millis(); millis() - t < 120000L; Particle.process())

    Log.trace("This OTA state after delay FW-Ver4");
}

The above code gets executed when a new firmware update is detected, but I don’t see any updates happen at all.

I just noticed my code keep looping for 2 minutes in this function displaying “This OTA state after delay FW-Ver4”.

Do I need to increase the delay? is this happening because there is not a good handshake between the device and the cloud?