My Argon continues to blink blue after I install updated code. Normally I run the following to clear the reset flag. I have recently upgraded my OS to 2.01. Has this changed the code necessary to clear this flag?
#include “Particle.h” #include “dct.h”
SYSTEM_MODE(AUTOMATIC); // ← Note use of AUTOMATIC mode!
void setup() {
// This clears the setup done flag on brand new devices so it won’t stay in listening mode
const uint8_t val = 0x01;
dct_write_app_data(&val, DCT_SETUP_DONE_OFFSET, 1);
}
That won’t work in AUTOMATIC mode. The reason is that setup() and loop() only run in AUTOMATIC without system thread if you are connected to the cloud and not in listening mode.
In that code, the code to set the setup done bit to avoid entering listening mode will never execute, if the setup done bit is not yet set, because the device will go into listening mode, and setup() won’t run.
You can get around this with any of these techniques:
Use SYSTEM_MODE(SEMI_AUTOMATIC) with a Particle.connect() in setup() after setting setup done
Use SYSTEM_THREAD(ENABLED)
Use the Particle CLI to set setup-done
Also if the Argon does not have Wi-Fi credentials it will go into listening mode regardless of the state of the setup done flag if the device is set to connect to Wi-Fi or the Particle cloud, including AUTOMATIC mode.