The State Machine Framework (SMF) is a Zephyr library that provides a way to implement hierarchical state machines in a structured manner. Most modules in the Asset Tracker Template implement a hierarchical state machine, where you can implement behavior common to multiple states in a shared parent state.
The state machines in the Asset Tracker Template follow a run-to-completion model where:
- Message processing and state machine execution, including transitions, are completed before processing any new messages.
- Entry and exit functions are called in the correct order when transitioning states.
- Parent state transitions are handled automatically when transitioning between child states.
This model ensures predictable behavior and proper state cleanup during transitions, as there is no mechanism for interrupting or changing the state machine execution from the outside.
This section covers how SMF is used in the modules in the Asset Tracker Template to implement state machines. See the SMF documentation for an introduction to SMF.