You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constwarning='Flashing firmware to a device replaces the existing user firmware binary on the device. This can only be undone by locating and flashing the previous firmware on the device.';
constwarning='Uploading a configuration schema replaces the existing configuration schema for all users of this product! An incorrect schema can cause errors opening your product in the console. A backup will be saved in your Downloads directory but you should still exercise caution.';
constwarning='Flashing firmware to a device replaces the existing user firmware binary on the device. This can only be undone by locating and flashing the previous firmware on the device.';
constwarning='Uploading a configuration schema replaces the existing configuration schema for all users of this product! An incorrect schema can cause errors opening your product in the console. A backup will be saved in your Downloads directory but you should still exercise caution.';
@@ -234,15 +234,15 @@ Upon waking up from sleep, we go into `STATE_WAIT_CONNECTED` state. We'll almost
234
234
235
235
This example just shows what the code would look like if we didn't use a state machine. For a simple example like this it may look cleaner, but as your code gets more complex it can get unwieldy quickly!
One example of the subtle gotchas that can occur: Say you decide to enable the `ApplicationWatchdog`. In each of the two inner delay loops you'd also have to add a call to `checkin()` otherwise the device could end up resetting if it was having trouble connecting. That's not necessary in the state machine examples because the code returns from `loop()` frequently.
240
240
241
241
## 03-If-Statement
242
242
243
243
This is basically the same as the **01-Simple** example except if uses an `if` statement instead of switch.
@@ -270,7 +270,7 @@ It's mostly just a matter of preference.
270
270
271
271
While this example is pretty simple, you can imagine if you have a complex program, putting everything in `loop()` with a `switch` or `if` statement can get unwieldy!
One common solution to this is to separate every state out into a separate function.
276
276
@@ -316,7 +316,7 @@ void stateWaitConnected() {
316
316
317
317
One annoyance of the **04-Case-Function** example is that every time you add a new state you need to add an enum value, a case in the switch statement, and a function.
One solution to this is to just dispense with the enum and use function pointers. This is used instead of the `State` variable in the previous examples.
322
322
@@ -368,7 +368,7 @@ void loop() {
368
368
369
369
We have a new header file `MainStateMachine.h`. Here's what's in it:
You normally declare the `MainStateMachine` as a global variable in your main source file. You should avoid doing much in the constructor, as there are limitations on what is safe at [global object construction time](https://docs.particle.io/reference/device-os/firmware/#global-object-constructors).
@@ -433,15 +433,15 @@ The configuration data that is sent between the device and cloud is described by
433
433
434
434
These are the fields that will be added. This not only describe the data, but match the configuration data in the user firmware, and are also used to describe the console user interface.
0 commit comments