On its own, I don’t see having the Wi-Fi AP being off and the device blinking green affecting the loop thread.
This is the code I used:
#include "Particle.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
SerialLogHandler logHandler;
const unsigned long LOOP_REPORT_PERIOD = 5000;
bool cloudUp = false;
bool wifiUp = false;
unsigned long lastLoopReport = 0;
int loopCount = 0;
void setup() {
Serial.begin();
Particle.connect();
}
void loop() {
loopCount++;
// Note whether Wi-Fi has gone up or down
if (WiFi.ready()) {
if (!wifiUp) {
Log.info("WiFi up");
wifiUp = true;
}
}
else {
if (wifiUp) {
Log.info("WiFi down");
wifiUp = false;
}
}
// Note whether cloud has gone up or down
if (Particle.connected()) {
if (!cloudUp) {
Log.info("Cloud up");
cloudUp = true;
}
}
else {
if (cloudUp) {
Log.info("Cloud down");
cloudUp = false;
}
}
// Report the number of times loop has been executed in the last 5 seconds
if (millis() - lastLoopReport >= LOOP_REPORT_PERIOD) {
lastLoopReport = millis();
Log.info("loopCount=%d", loopCount);
loopCount = 0;
}
}
The code logs when Wi-Fi and cloud go up and down. Also, it reports the number of times loop() is called every 5 seconds.
There’s the normal log (breathing cyan, AP is up and working):
0000002924 [app] INFO: Cloud up
0000005000 [app] INFO: loopCount=573109
0000010000 [app] INFO: loopCount=676523
0000015000 [app] INFO: loopCount=676552
0000020000 [app] INFO: loopCount=676356
0000025000 [app] INFO: loopCount=676602
0000030000 [app] INFO: loopCount=676491
0000035000 [app] INFO: loopCount=676782
And after unplugging the AP power. Note the loopCount stays roughly the same. The device was blinking green the whole time.
0000036585 [app] INFO: Cloud down
0000036806 [app] INFO: WiFi down
0000037524 [hal.wlan] INFO: Using internal antenna
0000037568 [hal.wlan] INFO: Joining Test
0000040000 [app] INFO: loopCount=655707
0000044577 [hal.wlan] ERROR: wiced_join_ap_specific(), result: 1024
0000044577 [hal.wlan] INFO: Joining Test
0000045000 [app] INFO: loopCount=678360
0000050000 [app] INFO: loopCount=678879
0000051674 [hal.wlan] ERROR: wiced_join_ap_specific(), result: 1024
And after I plugged the AP back in:
0000137460 [hal.wlan] INFO: Joining Test
0000140000 [app] INFO: loopCount=678333
0000144563 [hal.wlan] ERROR: wiced_join_ap_specific(), result: 1024
0000144705 [hal.wlan] INFO: Joining Test
0000145000 [app] INFO: loopCount=675422
0000145688 [hal.wlan] INFO: Bringing WiFi interface up with static IP
0000145693 [app] INFO: WiFi up
0000146975 [app] INFO: Cloud up
0000150000 [app] INFO: loopCount=615204
Tested on 0.8.0-rc.11 on a Photon.
Now I suspect there are cases where calling certain functions will adversely affect performance. In particular, calling Particle.publish() will block the calling thread completely in this state. It’s quite possible that other WiFi functions may block as well, but I haven’t tested the individual functions.
Just for a good measure I also tested the case where the AP is powered up but the Ethernet disconnected. The Photon was in blinking cyan in this case:
0001075000 [app] INFO: loopCount=676764
0001080000 [app] INFO: loopCount=676805
0001082934 [app] INFO: Cloud down
0001085000 [app] INFO: loopCount=677096
0001090000 [app] INFO: loopCount=680313
0001095000 [app] INFO: loopCount=680280
0001100000 [app] INFO: loopCount=680322
0001103182 [app] INFO: WiFi down
0001103903 [hal.wlan] INFO: Using internal antenna
0001103948 [hal.wlan] INFO: Joining Test
0001104829 [hal.wlan] INFO: Bringing WiFi interface up with static IP
0001104834 [app] INFO: WiFi up
0001105000 [app] INFO: loopCount=655643
0001110000 [app] INFO: loopCount=680338
0001115000 [app] INFO: loopCount=680379
0001120000 [app] INFO: loopCount=680232
0001122057 [app] INFO: Cloud up
0001125000 [app] INFO: loopCount=617026
The next step is probably to take the test program and add in other functions that you use to see which ones cause problems.