Our controller operated primarily on a 3-state flat state machine called FARMER_FSM, which managed the information passing between various software modules. This top service interfaced with RX and TX communication services, and various auxiliary services including the IMU LED display, accelerometer, and microphone services.
Main State Machine
This state machine ("FARMER_FSM") governed the overall performance of the controller. While waiting to pair, the controller would respond only to a pair event generated by blowing into the shell. Then while waiting for the pair response, the controller will only advance into the paired state if the appropriate response was received. Once paired, the controller was only unpaired if connection was lost.
These services governed the auxiliary functions of the controller, including tilt measurement, sound sensing, button pressing, and LED displays. In general, these were simple services with single event checkers rather than complete state machines.