I am running 0.7.0. And yes I am testing this with SYSTEM_THREAD(ENABLED).
What I mean by blocking is that it is preventing the rest of my user firmware from running. I originally wanted my user firmware to run on start up even if there is no cloud connection. I have a button that changes the state of a relay and the colour of an LED. If I have the Particle.function/Particle.variable function in the setup function, I am not able to control the relay using the button. However once I comment those out, the button works as soon as I power on the device. Here is a cut down version of the code.
//particle variable setup
//particle function setup
//pin mode setup
//interrupt for button to change relay state
attachInterrupt(buttonPin, interrupt_function, RISING);
There are no publish/subscribes. If I comment out all the Particle.function/variable calls, the device will work as intended. If I leave them there, it’ll wait for cloud connection before my button will work.
I also JUST noticed the documentation was updated to actually address this particular issue. https://docs.particle.io/reference/firmware/photon/#system-functions
Synchronous system functions always block the caller until the system has performed the requested operation. These are the synchronous system functions:
- WiFi.hasCredentials(), WiFi.setCredentials(), WiFi.clearCredentials()
For example, when the system is busy connecting to Wi-Fi or establishing the cloud connection and the application calls Particle.variable() then the application will be blocked until the system finished connecting to the cloud (or gives up) so that it is free to service the Particle.variable() function call.
This presents itself typically in automatic mode and where setup() registers functions, variables or subscriptions. Even though the application thread is running setup() independently of the system thread, calling synchronous functions will cause the application to block until the system thread has finished connecting to the cloud. This can be avoided by delaying the cloud connection until after the synchronous functions have been called.
Does that mean I should be using semi-automatic/manual mode? If so, I’m assuming I’ll have to constantly call Particle.process as well as Particle.connect when it loses cloud connection?