System modes
Automatic mode (threading enabled)
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);
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.