Gotcha. So is this kinda what you are thinking?
bool updateOccuring = false;
//AFTER WE GRAB SENSOR DATA, CONNECT, AND PUBLISH
if (updateOccuring){
downloadUpdate();
}
void otaHandler () {
Serial.println("Update is pending. Will reboot after update.");
updateOccuring = true;
}
void downloadUpdate(){
Particle.publish("Updating pending.", "True", 60, PRIVATE); //for troubleshooting
loop_count = 0;
while (loop_count < 600) {
Particle.process();
delay(100);
loop_count++;
}
}