Execution delay when offline

So I need some code to execute as soon as possible wether or not the device is online.

When it has a WiFi connection available the code executes within 2-3 seconds of plugging in the power. However if the WiFi is down when it gets plugged in this is delayed up to 11-13 seconds.

I’ve tried putting the code above server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 10.0); so it’s the first thing that gets executed, but that didn’t speed it up.

I’ve tried to reduce the timeoutpolicy down from 10.0 but that had no effect.

Is there something else in play delaying things before our code gets executed?


No, the 10s delay is compulsory when waking due to power-on. (It shouldn’t occur when waking from deep-sleep.) It’s a protection mechanism, to guard against Squirrel disconnecting from wifi, never reconnecting, and bricking the imp.