My electron usually works fine. Sporadically however, it will demonstrate the following pattern when it tries to connect:
Blinking Green > Rapid Cyan > Breathing Cyan > lock-up while Blinking Cyan (5-10mins.) > Sleep
When this happens, the device connects to the Cloud but no data gets published. I’m using 3rd Party SIMs (Bell).
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
STARTUP(System.enableFeature(FEATURE_RESET_INFO));
STARTUP(cellular_credentials_set("mnet.bell.ca.ioe", "", "", NULL));
void setup() {
...
}
void loop() {
switch(state) {
...
case CONNECT:
Cellular.on();
for (uint32_t ms = millis(); millis() - ms < 1000; Particle.process());
Particle.connect();
for (uint32_t ms = millis(); millis() - ms < 10000; Particle.process());
if (waitFor(Particle.connected, 180000)) {
for (uint32_t ms = millis(); millis() - ms < 5000; Particle.process());
stateTime = millis();
state = PUBLISH;
break;
}
else {
state = SLEEP;
break;
}
break;
case PUBLISH:
sig = Cellular.RSSI();
rsi = sig.rssi;
snprintf(data, sizeof(data), "{\"xx1\": \"%i\", \"xx2\": \"%i\", \"cll\": \"%i\", \"fd1\": \"%i\", \"fd2\": \"%i\", \"fll\": \"%i\", \"lat\": \"%.02f\", \"lng\": \"%.02f\", \"tmz\": \"%i\", \"rsi\": \"%i\"}", xx1, xx2, cll, fd1, fd2, fll, lat, lng, tmz, rsi);
Serial.println(data);
Particle.publish(publish, data, PRIVATE, NO_ACK);
for (uint32_t ms = millis(); millis() - ms < 5000; Particle.process());
state = SLEEP;
break;
case SLEEP:
Particle.disconnect(); //turning off modem
for (uint32_t ms = millis(); millis() - ms < 1000; Particle.process());
Cellular.off();
for (uint32_t ms = millis(); millis() - ms < 2000; Particle.process());
snprintf(buffer, sizeof(buffer), "until next wake-up: %02i:%02i:%02i", sleepTime / 3600, (sleepTime % 3600) / 60, sleepTime % 60);
Serial.println(buffer);
delay(500);
System.sleep(SLEEP_MODE_DEEP, sleepTime);
break;
}
}
The Electron will eventually go to Sleep, but the execution of code is severely delayed.
Does anyone have an idea of what may be going wrong here?