System modes
Manual mode
There are many hidden pitfalls when using MANUAL
system mode with cloud connectivity, and it may interact unexpectedly with threading.
The only recommended use case for MANUAL
mode is when you have no cloud connectivity at all, such as when you are using the device with no
cloud connectivity at all. For example, if you are only using BLE or NFC.
SYSTEM_MODE(MANUAL);
void setup() {
// This will run automatically
}
void loop() {
if (buttonIsPressed()) {
Particle.connect();
}
if (Particle.connected()) {
doOtherStuff();
}
Particle.process();
}
When using manual mode:
- The user code will run immediately when the device is powered on.
- Once the user calls
Particle.connect()
, the device will attempt to begin the connection process. - Once the device is connected to the Cloud (
Particle.connected()
== true
), the user must callParticle.process()
regularly to handle incoming messages and keep the connection alive. The more frequentlyParticle.process()
is called, the more responsive the device will be to incoming messages. - If
Particle.process()
is called less frequently than every 20 seconds, the connection with the Cloud will die. It may take a couple of additional calls ofParticle.process()
for the device to recognize that the connection has been lost. Particle.process()
is required even with threading enabled in MANUAL mode.