|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Implementation of the login state machine dispatcher. More...
Functions | |
| void | OpenLcbLoginStateMachine_initialize (const interface_openlcb_login_state_machine_t *interface_openlcb_login_state_machine) |
| Stores the callback interface and wires up the outgoing message buffer. | |
| void | OpenLcbLoginStateMachine_process (openlcb_login_statemachine_info_t *openlcb_statemachine_info) |
| Dispatches to the handler matching node->run_state. | |
| bool | OpenLcbLoginStatemachine_handle_outgoing_openlcb_message (void) |
| Tries to send the pending outgoing message. | |
| bool | OpenLcbLoginStatemachine_handle_try_reenumerate (void) |
| Re-enters the current handler if the enumerate flag is set. | |
| bool | OpenLcbLoginStatemachine_handle_try_enumerate_first_node (void) |
| Gets the first node and processes it if login is not complete. | |
| bool | OpenLcbLoginStatemachine_handle_try_enumerate_next_node (void) |
| Advances to the next node and processes it if login is not complete. | |
| void | OpenLcbLoginMainStatemachine_run (void) |
| Runs one non-blocking step of login processing. Call from main loop. | |
| openlcb_login_statemachine_info_t * | OpenLcbLoginStatemachine_get_statemachine_info (void) |
| Returns pointer to internal state machine info. For unit testing only. | |
Implementation of the login state machine dispatcher.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This module implements the main dispatcher for the OpenLCB login state machine. It manages the complete node initialization sequence by coordinating:
Architecture Overview: The state machine uses a polling architecture where OpenLcbLoginMainStatemachine_run() is called repeatedly from the main application loop. Each call performs one atomic operation and returns immediately, maintaining a non-blocking design.
Processing Flow (per call to run function):
State Dispatch Logic: The process function examines the node's run_state and calls the appropriate handler from the interface:
Multi-Message Sequences: For nodes with multiple producer or consumer events, handlers set the enumerate flag to trigger re-entry without advancing to the next node. This allows sending multiple messages in sequence while maintaining the non-blocking design.
Internal State: The module maintains static state including:
| void OpenLcbLoginStateMachine_initialize | ( | const interface_openlcb_login_state_machine_t * | interface_openlcb_login_state_machine | ) |
Stores the callback interface and wires up the outgoing message buffer.
Stores the callback interface. Call once at startup after OpenLcbLoginMessageHandler_initialize().
Algorithm:
* @param interface_openlcb_login_state_machine Pointer to interface structure *
| void OpenLcbLoginStateMachine_process | ( | openlcb_login_statemachine_info_t * | openlcb_statemachine_info | ) |
Dispatches to the handler matching node->run_state.
Dispatches to the handler matching node->run_state. Exposed for unit testing.
Algorithm:
* @param openlcb_statemachine_info Pointer to state machine info with node and message buffer *
| bool OpenLcbLoginStatemachine_handle_outgoing_openlcb_message | ( | void | ) |
Tries to send the pending outgoing message.
Tries to send the pending message; returns true if one was pending. Exposed for unit testing.
Algorithm:
| bool OpenLcbLoginStatemachine_handle_try_reenumerate | ( | void | ) |
Re-enters the current handler if the enumerate flag is set.
Re-enters the state processor if the enumerate flag is set. Exposed for unit testing.
Algorithm:
| bool OpenLcbLoginStatemachine_handle_try_enumerate_first_node | ( | void | ) |
Gets the first node and processes it if login is not complete.
Starts enumeration from the first node if none is active. Exposed for unit testing.
Algorithm:
| bool OpenLcbLoginStatemachine_handle_try_enumerate_next_node | ( | void | ) |
Advances to the next node and processes it if login is not complete.
Advances to the next node needing login. Exposed for unit testing.
Algorithm:
| void OpenLcbLoginMainStatemachine_run | ( | void | ) |
Runs one non-blocking step of login processing. Call from main loop.
Algorithm:
| openlcb_login_statemachine_info_t * OpenLcbLoginStatemachine_get_statemachine_info | ( | void | ) |
Returns pointer to internal state machine info. For unit testing only.
Returns pointer to internal static state machine info. For unit testing only — do not modify.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License