How to know when blinkup LED's are active

I am using a third status LED in the same light pipe as the blinkup red and green status LED’s.

Is there a software way to know when blinkup LED’s are active, in order to avoid indicating with the third LED during those times? I am using IMP002.

The only sure way I can find, is to hardwire pin 3 and 4 (LED_GREEN and LED_RED) to a couple of IMP002 input pins configured as digital input, and use a callback function?

Thanks philmy that’s it. Also included WAKEREASON_SW_RESET happening with an actual blinkup in the period.

2014-10-02 09:42:57 UTC+2 [Status] Downloading new code; 2.31% program storage used 2014-10-02 09:42:58 UTC+2 [Device] hardware.wakereason: 0 2014-10-02 09:43:25 UTC+2 [Status] Device Booting; 2.31% program storage used 2014-10-02 09:43:25 UTC+2 [Device] hardware.wakereason: 2 2014-10-02 09:44:21 UTC+2 [Device] blink 2014-10-02 09:44:22 UTC+2 [Device] blink 2014-10-02 09:44:23 UTC+2 [Device] blink

The code below delays own LED blinking with 60 sec if cold booting.

This code works when the imp immediately connects to a wifi router. However, if the wifi router is enabled 20 sec after the Imp is turned on, there is a 20+ sec gap between blinkup status LED’s stopping and the extra LED starts blinking …

So the challenge seems to be, not knowing when the server connection succeded, compared to when the 60 sec. connection timer controlling the blinkup LED’s was started?


  • Control a blinking LED to only be active when
  • imp status LED’s are not active
  • ********************************************/

// Blink our LED
function BlinkLED(){
imp.wakeup(1.30, BlinkLED);

// Setup our LED
led <- hardware.pin2
led.configure(DIGITAL_OUT, 0);

// Wait with our status LED untill blinkup status LED’s are done
server.log("hardware.wakereason: " + hardware.wakereason());
if(hardware.wakereason() == WAKEREASON_POWER_ON) imp.wakeup(60, BlinkLED);
else BlinkLED();

BlinkUp status functions are in the feature queue. In the meantime you could try using clock():

startclock <- clock() if(hardware.wakereason() == WAKEREASON_POWER_ON) { imp.wakeup(60-startclock,function(){ server.log("BlinkUp stopping") }) }

In RETURN_ON_ERROR mode with blinkup enabled, it remains unreliable to guestimate the timing of where the Imp is in the wifi state diagram in combination with 9 hardware startup reasons and the user doing blinkup at a random point during the startup.

The hardware method mentioned in the start is easy and works very well with one exception: during blinkup, the blinkup led’s are passive.

I see this working reliably when a device.blinkupisactive() or similar becomes available.