State machines

Serial Modem Host Applications

tags
Serial Modem Host Applications

The State Machine Framework (SMF) is a Zephyr library that provides a way to implement hierarchical state machines in a structured manner. In a hierarchical state machine, you can implement behavior common to multiple states in a shared parent state. In the PPP Host Application, the Main and FOTA modules and the Location library backend of the Location module use hierarchical state machines, while the Network and Cloud modules are simple enough to use flat ones.

The state machines 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. See the SMF documentation for an introduction to SMF.