System modes
Automatic mode (threading enabled)
SYSTEM_MODE(AUTOMATIC);
#ifndef SYSTEM_VERSION_v620
SYSTEM_THREAD(ENABLED); // System thread defaults to on in 6.2.0 and later and this line is not required
#endif
void setup() {
// This is called even before being cloud connected
}
void loop() {
// This is too
}
When also using SYSTEM_THREAD(ENABLED)
, the following are true even in AUTOMATIC
mode:
- When the device starts up, it automatically tries to connect to Wi-Fi or Cellular and the Particle Device Cloud.
- Messages to and from the Cloud are handled from a separate thread and are mostly unaffected by operations in loop.
- If you block loop() from returning you can still impact the following:
- Function calls
- Variable retrieval
- Serial events
Using SYSTEM_THREAD(ENABLED)
is recommended. With Device OS 6.2.0 and later, system thread is always enabled. For additional information, see non-threaded system mode.