OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
openlcb_login_statemachine_handler.h File Reference

Message construction handlers for the login sequence. More...

Go to the source code of this file.

Data Structures

struct  interface_openlcb_login_message_handler_t
 Callbacks that map event state to the correct Identified MTI. Both REQUIRED. More...
 

Functions

void OpenLcbLoginMessageHandler_initialize (const interface_openlcb_login_message_handler_t *interface)
 Stores the callback interface. Call once at startup before login processing.
 
void OpenLcbLoginMessageHandler_load_initialization_complete (openlcb_login_statemachine_info_t *statemachine_info)
 Builds the Initialization Complete message and transitions to producer event enumeration.
 
void OpenLcbLoginMessageHandler_load_producer_event (openlcb_login_statemachine_info_t *statemachine_info)
 Builds one Producer Identified message; sets enumerate flag if more remain.
 
void OpenLcbLoginMessageHandler_load_consumer_event (openlcb_login_statemachine_info_t *statemachine_info)
 Builds one Consumer Identified message; sets enumerate flag if more remain.
 

Detailed Description

Message construction handlers for the login sequence.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

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.

Builds Initialization Complete, Producer Identified, and Consumer Identified messages during the node login process. Each handler advances the login state machine and sets the enumerate flag when multiple messages must be sent for a single state transition.

Author
Jim Kueneman
Date
4 Mar 2026

Function Documentation

◆ OpenLcbLoginMessageHandler_initialize()

void OpenLcbLoginMessageHandler_initialize ( const interface_openlcb_login_message_handler_t * interface)
extern

Stores the callback interface. Call once at startup before login processing.

Parameters
interfacePointer to interface_openlcb_login_message_handler_t. Must remain valid for application lifetime.

Stores the callback interface. Call once at startup before login processing.

* @param interface Pointer to interface structure containing callback functions
* 

◆ OpenLcbLoginMessageHandler_load_initialization_complete()

void OpenLcbLoginMessageHandler_load_initialization_complete ( openlcb_login_statemachine_info_t * statemachine_info)
extern

Builds the Initialization Complete message and transitions to producer event enumeration.

Parameters
statemachine_infoPointer to openlcb_login_statemachine_info_t context.

Algorithm:

  1. Pick MTI_INITIALIZATION_COMPLETE or _SIMPLE based on PSI_SIMPLE flag
  2. Load message header and copy 6-byte Node ID into payload
  3. Mark node initialized, set up producer enumerator, set valid flag
  4. Transition to RUNSTATE_LOAD_PRODUCER_EVENTS
* @param statemachine_info Pointer to state machine info containing node and message buffer
* 

◆ OpenLcbLoginMessageHandler_load_producer_event()

void OpenLcbLoginMessageHandler_load_producer_event ( openlcb_login_statemachine_info_t * statemachine_info)
extern

Builds one Producer Identified message; sets enumerate flag if more remain.

Skips to consumer enumeration when all producers are done or count is 0.

Parameters
statemachine_infoPointer to openlcb_login_statemachine_info_t context.

Algorithm:

  1. If no producers, skip to RUNSTATE_LOAD_CONSUMER_EVENTS
  2. Emit range events first, then normal events
  3. For each event: get MTI from callback, copy Event ID to payload
  4. Set enumerate=true and valid=true for each message
  5. When all done, reset enumerator and transition to consumer events
* @param statemachine_info Pointer to state machine info containing node and message buffer
* 

◆ OpenLcbLoginMessageHandler_load_consumer_event()

void OpenLcbLoginMessageHandler_load_consumer_event ( openlcb_login_statemachine_info_t * statemachine_info)
extern

Builds one Consumer Identified message; sets enumerate flag if more remain.

Final login step — transitions to RUNSTATE_LOGIN_COMPLETE when all consumers are done or count is 0.

Parameters
statemachine_infoPointer to openlcb_login_statemachine_info_t context.

Algorithm:

  1. If no consumers, skip to RUNSTATE_LOGIN_COMPLETE
  2. Emit range events first, then normal events
  3. For each event: get MTI from callback, copy Event ID to payload
  4. Set enumerate=true and valid=true for each message
  5. When all done, reset enumerator and transition to RUNSTATE_LOGIN_COMPLETE
* @param statemachine_info Pointer to state machine info containing node and message buffer
* 

Copyright (c) 2026 Jim Kueneman all rights reserved. See the License