I’ve reformatted your code blocks.
To see how it’s done tap the pencil icon to edit your post and see how I did it.
Also look at
Forum Tips and Tricks
Code hints:
while (1) {
Serial.println("Faaaaaale");
}
This will stall the cloud connection and hence stop you from flashing new code over the air.
Add a call to Particle.process()
wherever you could be kept for more than 10sec.