Hi there fellow Particle geeks!
I am having some trouble with auto-updates (OTA) with Particle Electrons that belong to a product group. Wondering if someone can point me in the right direction.
First, the devices are currently on 0.6.0 with a 3rd party SIM.
Keepalive is set at 30 currently.
SYSTEM_MODE(SEMI_AUTOMATIC);
Typical setup where the device comes out of sleep, collects some sensor date, publishes it, then goes back to sleep.
I have the following in my setup function.
System.on(firmware_update_pending, otaHandler);
For the otaHandler, I have the following.
void otaHandler () {
Serial.println("Update is pending. Will reboot after update.");
if (Particle.connected() == false) {
Particle.connect();
}
Particle.publish("Updating pending.", "True", 60, PRIVATE); //for troubleshooting
loop_count = 0;
while (loop_count < 6) {
Particle.process();
delay(10000);
loop_count++;
}
}
This might be overkill, but I’m just trying to keep it alive long enough to get the update.
Currently in the event logs on the console, I will see
spark/status - auto-update
I will get my “Update pending” publish indicating that the otaHandler is running.
The device will continue breathing cyan. Then after about a minute I will see
spark/flash/status - failed.
The device will continue breathing cyan for a while and then will go back to sleep.
I have let this run through it’s normal course several times and it just fails to update the device with the new firmware.
I have also re-compiled the firmware a few times to make sure I was targeting the correct system firmware. Have made sure I had a device marked as DEV running this firmware successfully before releasing it to the product.
I have also attempted to update the DEV device to 0.7.0, compiling the firmware targeting 0.7.0 and releasing. This gives some interesting results.
When updating a device OTA, the same as above happens, but the device goes into safe mode to update the system firmware from 0.6.0 to 0.7.0. This indicates to me that the process is happening as I would expect. Then the device will go to sleep and wake up as expected for the next check in, but the process starts over indicating that it had failed to update the system firmware as well.