I have the code below. Occasionally, when this case gets initiated an Electron will show a solid green LED (no blinking/breathing). What may cause such behaviour? Is it Particle.syncTime()?
I’ve never really come across a solid green before - does it mean the code is blocking?
case CONNECT:
xl.readXYZTData(X, Y, Z, T);
if (!initCON) {
Serial.println("connecting to the cellular network and Particle Cloud. Please allow up to 90 seconds.");
EEPROM.get(addMode, mode);
EEPROM.get(addX1, X1);
EEPROM.get(addCollection, collection);
EEPROM.get(addRebootno, rebootNo);
Particle.connect();
initCON = true;
}
if (isValid(X) && millis() - sampleTime >= 500) {
sampleTime = millis();
X2 = std::abs(X-X1);
if (!collection && X2 >= 400) {
state = XL;
break;
}
}
if (Particle.connected()) {
Serial.println("connection established!");
Particle.publish("spark/device/session/end", PRIVATE);
Particle.syncTime();
if (mode == 1) {
stateTime = millis();
state = GPS;
break;
}
else {
stateTime = millis();
state = PUBLISH;
break;
}
}
if (millis() - stateTime >= 90000) {
if (rebootNo < 3) {
EEPROM.put(addReboot, true);
EEPROM.put(addRebootno, rebootNo + 1);
snprintf(buffer, sizeof(buffer), "This is connection attempt %i. re-attempting in 10 seconds.", rebootNo);
Serial.println(buffer);
Cellular.off();
delay(2000);
System.sleep(SLEEP_MODE_DEEP, 10);
break;
}
else {
Serial.println("connection attempt threshold reached");
state = SLEEP;
break;
}
}
break;
On another note, I notice sometimes that when this code runs:
if (rebootNo < 3) {
EEPROM.put(addReboot, true);
EEPROM.put(addRebootno, rebootNo + 1);
snprintf(buffer, sizeof(buffer), "This is connection attempt %i. re-attempting in 10 seconds.", rebootNo);
Serial.println(buffer);
Cellular.off();
delay(2000);
System.sleep(SLEEP_MODE_DEEP, 10);
break;
}
The message prints fine, but the Electron remains stuck in blinking green/cyan (whatever it’s doing) and not actually turn off the Cellular and go to Sleep. Am I missing something here about the Cellular.off() functionality?
EDIT: I’m starting to think this specific Electron may just be broken…the behaviour here is very strange and not in line with any of my other Electrons.