Device LED still blinks (trying to join wifi network) despite imp.enableblinkup(false)

I need to be able to disable the device LED. I found that if you set imp.enableblinkup() to false, it does so for the majority of cases.

However, recently I’ve discovered that after 10 minutes of being disconnected, something happens that causes the device’s LED to blink. The code that blinks is the “joining wifi network”. red long 1x, red short 3x. It repeats that sequence several times, goes dark, and again blinks every 10 minutes.

The imp.enableblinkup(false) code is literally the first thing in my device code. What is causing my device’s LED to blink? Is there a way to prevent that?

The only time that enableblinkup() being false does not disable the LED is within 1 min of a cold boot; this is to ensure that you can blinkup a device even if it disables blinkup (a common trap people can get themselves into!)

How is your device powered? A power glitch could cause a cold boot, which would match what you’re seeing.

Hi Hugo,

The device as I tested it this morning is on battery. I can test USB power once I get home. I set it to deep sleep on an interval. Could that trigger this behavior?

Some additional info - i have imp.setpowersave(true) set in my code, and i’m on an imp003 board. From documentation it doesn’t seem like it should affect anthing.

Seems to still be happening on wall power. 10 minutes after the wifi network goes down, just like on battery.

i think i’ve figured it out. the issue was i was using the deep sleep mode. this causes a cold boot to happen (to the best of my understanding)

edit: nvm… I got rid of the deep sleep mode, but it still blinks after 10 mins of being disconnected. Back to the drawing board :frowning:

Can you share some of your code? What’s being logged when the network appears to go down?

After deep sleep, the imp performs a warm boot, not a cold start — it restarts the Squirrel VM and begins running code fresh. At this point it is not connected and will stay that way until your code attempts to access the server — or, if you have your server.setsendtimeoutpolicy() set to RETURN_ON_ERROR, when you call server.connect().

The 10-minute period suggests to me that your device is trying to connect at some point, failing and, because your server.setsendtimeoutpolicy() is defaulting or explicitly set to SUSPEND_ON_ERROR, going into deep sleep for 9 minutes (after a 1-minute timeout).

Does your code log something early in its run? That would cause the imp to reconnect (hence the LED activity) once its woken after 10 minutes.

Take a look at the Network State Diagram, which shows the stages an imp goes through. Note that an error in your code will also trigger a connection attempt (because it checks for new, hopefully error-free Squirrel) which, if the imp can’t connect, will lead to the 10-minute sleep-then-restart.

This is indeed what was going on.

Thank you for the help.