#endifflow instructions to enable (or not) an advanced and thorough debug mode, as done in some of our libraries (GPRS Pro or 3G).
if()condition to control the code flow and make more efficient. For example, you will not want to send an SMS with the GPRS module if the connection to the GPRS network was not possible. You can build nested
if()structures to do things only when you need to do it. Take a look to the API, many functions deliver 0/1 as an output to show if the execution was successful.
while()loop is suitable to be stuck because the exit condition is never satisfied. Instead of putting a single exit condition, add a second one with the OR (
||) operator. This second condition can be a counter which is incremented in each while loop. This will help to implement a kind of timeout: "if this while loop was executed 100 times, then exit". A second strategy to avoid infinite while loops is to use
breakinside the while loop.
millis()function measures the execution time since Waspmote is turned ON. It can be very useful to measure how much time your functions spend carrying out their tasks (subtracting the value after something with the value before). It can be a sign of malfunction: if a loop normally takes 4 seconds to be executed and now it took 10 seconds... something could go wrong.