I am pretty new to particle and I was looking at the code of AssetTrackerRK, in particular to this example:
The whole thing is basically a FSM and some states are just there to loose time waiting for something to happen (e.g., a message is sent, device is fully booted, …).
I am aware that sometimes is ok to use delay() while sometime is good to have a manually crafted “soft-delay” that allows you to do some other operations while you wait, see hereafter:
However I was wondering if in some cases the soft wait could be changed in favor of a delay() for example in the code of linked above of AssetTrackerRK.
For example the state BOOT_WAIT_STATE (line 147) where the code just waits for a while to make sure the electron is fully operative could be substituted with a delay(). Correct? Similarly with SLEEP_WAIT_STATE (line 141).
From this doubt an additional question comes into play. Assume for example I want to send a message with Particle.publish(…) and then go to sleep. After publishing I cannot immediately invoke Particle.sleep(…) because I need to let the device have the time to send the message (correct?).
Instead, can I use a delay() and immediately after go to sleep? In other words does the delay let the Particle code run or freezes everything? Does it freeze only my code and my libraries or every single line of code executed by the device?
Thank you for the clarification and sorry if the question is trivial (I am pretty new to the embedded world).