← Back to the chapter · Previous detail
Technical detail · Device State Machines: Modes and Safety
Dispatch, overlapping events, and reboot
A transition table can drive the code as well as the review. Look up the current state and event, test the guards in a known order, run the chosen action, and record the result. Reject events that have no valid row. If an action can be retried, make it safe to repeat. Tests can then compare the table, code, and logs for the same event.
Events can also overlap. A cloud command may arrive during reconnect, or power may fail after an action but before its state is saved. Define how state writes and actions stay consistent across a reboot. Use command sequence numbers to reject old work, and choose whether startup resumes, rolls back, or enters a safe state. Compare desired and reported shadow versions before applying an old cloud value.