OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
interface_openlcb_main_statemachine_t Struct Reference

Dependency-injection interface for the main state machine. Required pointers must be non-NULL; optional ones may be NULL (causes automatic Interaction Rejected). Internal pointers are exposed for unit testing. More...

Data Fields

void(* lock_shared_resources )(void)
 Disable interrupts / acquire mutex. Keep short. REQUIRED.
 
void(* unlock_shared_resources )(void)
 Re-enable interrupts / release mutex. REQUIRED.
 
bool(* send_openlcb_msg )(openlcb_msg_t *outgoing_msg)
 Queue a message for transmission. Return false if buffer full. REQUIRED.
 
uint8_t(* get_current_tick )(void)
 Return current value of the global 100ms tick counter. REQUIRED.
 
openlcb_node_t *(* openlcb_node_get_first )(uint8_t key)
 Return first node (NULL if none). key separates concurrent iterations. REQUIRED.
 
openlcb_node_t *(* openlcb_node_get_next )(uint8_t key)
 Return next node (NULL at end). REQUIRED.
 
bool(* openlcb_node_is_last )(uint8_t key)
 Return true if current enumeration position is the last node. REQUIRED.
 
uint16_t(* openlcb_node_get_count )(void)
 Return the number of allocated nodes. REQUIRED.
 
void(* load_interaction_rejected )(openlcb_statemachine_info_t *statemachine_info)
 Build Optional Interaction Rejected for unhandled MTIs. REQUIRED.
 
void(* message_network_initialization_complete )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0100 — Initialization Complete. REQUIRED.
 
void(* message_network_initialization_complete_simple )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0101 — Initialization Complete Simple. REQUIRED.
 
void(* message_network_verify_node_id_addressed )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0488 — Verify Node ID Addressed. REQUIRED.
 
void(* message_network_verify_node_id_global )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0490 — Verify Node ID Global. REQUIRED.
 
void(* message_network_verified_node_id )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0170/0x0171 — Verified Node ID. REQUIRED.
 
void(* message_network_optional_interaction_rejected )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0068 — Optional Interaction Rejected (received). REQUIRED.
 
void(* message_network_terminate_due_to_error )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x00A8 — Terminate Due to Error. REQUIRED.
 
void(* message_network_protocol_support_inquiry )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0828 — Protocol Support Inquiry. REQUIRED.
 
void(* message_network_protocol_support_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0668 — Protocol Support Reply (received). REQUIRED.
 
void(* process_main_statemachine )(openlcb_statemachine_info_t *statemachine_info)
 MTI dispatcher — routes incoming message to the correct handler.
 
bool(* does_node_process_msg )(openlcb_statemachine_info_t *statemachine_info)
 Address filter — returns true if node should process this message.
 
bool(* handle_outgoing_openlcb_message )(void)
 Try to send the pending outgoing message; returns true if one was pending.
 
bool(* handle_try_reenumerate )(void)
 Re-enter the state processor if the enumerate flag is set.
 
bool(* handle_try_pop_next_incoming_openlcb_message )(void)
 Pop next incoming message from the FIFO (thread-safe).
 
bool(* handle_try_enumerate_first_node )(void)
 Start enumeration from the first node.
 
bool(* handle_try_enumerate_next_node )(void)
 Advance to the next node; frees message when enumeration completes.
 
void(* snip_simple_node_info_request )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0DE8 — Simple Node Info Request. Optional.
 
void(* snip_simple_node_info_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0A08 — Simple Node Info Reply (received). Optional.
 
void(* event_transport_consumer_identify )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x08F4 — Identify Consumer. Optional.
 
void(* event_transport_consumer_range_identified )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x04A4 — Consumer Range Identified. Optional.
 
void(* event_transport_consumer_identified_unknown )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x04C7 — Consumer Identified Unknown. Optional.
 
void(* event_transport_consumer_identified_set )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x04C4 — Consumer Identified Set. Optional.
 
void(* event_transport_consumer_identified_clear )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x04C5 — Consumer Identified Clear. Optional.
 
void(* event_transport_consumer_identified_reserved )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x04C6 — Consumer Identified Reserved. Optional.
 
void(* event_transport_producer_identify )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0914 — Identify Producer. Optional.
 
void(* event_transport_producer_range_identified )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0524 — Producer Range Identified. Optional.
 
void(* event_transport_producer_identified_unknown )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0547 — Producer Identified Unknown. Optional.
 
void(* event_transport_producer_identified_set )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0544 — Producer Identified Set. Optional.
 
void(* event_transport_producer_identified_clear )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0545 — Producer Identified Clear. Optional.
 
void(* event_transport_producer_identified_reserved )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0546 — Producer Identified Reserved. Optional.
 
void(* event_transport_identify_dest )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0968 — Identify Events Addressed. Optional.
 
void(* event_transport_identify )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0970 — Identify Events Global. Optional.
 
void(* event_transport_learn )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0594 — Learn Event. Optional.
 
void(* event_transport_pc_report )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x05B4 — PC Event Report. Optional.
 
void(* event_transport_pc_report_with_payload )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x05F4 — PC Event Report with Payload. Optional.
 
void(* train_control_command )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x05EB — Train Control Command. Optional.
 
void(* train_control_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x01E9 — Train Control Reply (received). Optional.
 
void(* simple_train_node_ident_info_request )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0DA8 — Simple Train Node Ident Info Request. Optional.
 
void(* simple_train_node_ident_info_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0A48 — Simple Train Node Ident Info Reply (received). Optional.
 
void(* datagram )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x1C48 — Datagram. Must reply OK or Rejected. Optional.
 
void(* datagram_ok_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0A28 — Datagram Received OK (received). Optional.
 
void(* load_datagram_rejected )(openlcb_statemachine_info_t *statemachine_info, uint16_t error_code)
 Build Datagram Rejected reply. Optional — called when datagram handler is NULL.
 
void(* datagram_rejected_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0A48 — Datagram Rejected (received). Optional.
 
void(* stream_initiate_request )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0CC8 — Stream Initiate Request. Optional.
 
void(* stream_initiate_reply )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0868 — Stream Initiate Reply (received). Optional.
 
void(* stream_send_data )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x1F88 — Stream Data Send. Optional.
 
void(* stream_data_proceed )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x0888 — Stream Data Proceed (received). Optional.
 
void(* stream_data_complete )(openlcb_statemachine_info_t *statemachine_info)
 MTI 0x08A8 — Stream Data Complete (received). Optional.
 
void(* broadcast_time_event_handler )(openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Called by the event transport handler for broadcast time Event IDs. Optional.
 
void(* train_search_event_handler )(openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Called for train search events; dispatched to every train node. Optional.
 
void(* train_search_no_match_handler )(openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Called when train search enumeration completes with no match. Optional.
 
void(* train_emergency_event_handler )(openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Called for well-known emergency events; dispatched to every train node. Optional.
 

Detailed Description

Dependency-injection interface for the main state machine. Required pointers must be non-NULL; optional ones may be NULL (causes automatic Interaction Rejected). Internal pointers are exposed for unit testing.

Field Documentation

◆ lock_shared_resources

void(* lock_shared_resources) (void)

Disable interrupts / acquire mutex. Keep short. REQUIRED.

◆ unlock_shared_resources

void(* unlock_shared_resources) (void)

Re-enable interrupts / release mutex. REQUIRED.

◆ send_openlcb_msg

bool(* send_openlcb_msg) (openlcb_msg_t *outgoing_msg)

Queue a message for transmission. Return false if buffer full. REQUIRED.

◆ get_current_tick

uint8_t(* get_current_tick) (void)

Return current value of the global 100ms tick counter. REQUIRED.

◆ openlcb_node_get_first

openlcb_node_t *(* openlcb_node_get_first) (uint8_t key)

Return first node (NULL if none). key separates concurrent iterations. REQUIRED.

◆ openlcb_node_get_next

openlcb_node_t *(* openlcb_node_get_next) (uint8_t key)

Return next node (NULL at end). REQUIRED.

◆ openlcb_node_is_last

bool(* openlcb_node_is_last) (uint8_t key)

Return true if current enumeration position is the last node. REQUIRED.

◆ openlcb_node_get_count

uint16_t(* openlcb_node_get_count) (void)

Return the number of allocated nodes. REQUIRED.

◆ load_interaction_rejected

void(* load_interaction_rejected) (openlcb_statemachine_info_t *statemachine_info)

Build Optional Interaction Rejected for unhandled MTIs. REQUIRED.

◆ message_network_initialization_complete

void(* message_network_initialization_complete) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0100 — Initialization Complete. REQUIRED.

◆ message_network_initialization_complete_simple

void(* message_network_initialization_complete_simple) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0101 — Initialization Complete Simple. REQUIRED.

◆ message_network_verify_node_id_addressed

void(* message_network_verify_node_id_addressed) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0488 — Verify Node ID Addressed. REQUIRED.

◆ message_network_verify_node_id_global

void(* message_network_verify_node_id_global) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0490 — Verify Node ID Global. REQUIRED.

◆ message_network_verified_node_id

void(* message_network_verified_node_id) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0170/0x0171 — Verified Node ID. REQUIRED.

◆ message_network_optional_interaction_rejected

void(* message_network_optional_interaction_rejected) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0068 — Optional Interaction Rejected (received). REQUIRED.

◆ message_network_terminate_due_to_error

void(* message_network_terminate_due_to_error) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x00A8 — Terminate Due to Error. REQUIRED.

◆ message_network_protocol_support_inquiry

void(* message_network_protocol_support_inquiry) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0828 — Protocol Support Inquiry. REQUIRED.

◆ message_network_protocol_support_reply

void(* message_network_protocol_support_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0668 — Protocol Support Reply (received). REQUIRED.

◆ process_main_statemachine

void(* process_main_statemachine) (openlcb_statemachine_info_t *statemachine_info)

MTI dispatcher — routes incoming message to the correct handler.

◆ does_node_process_msg

bool(* does_node_process_msg) (openlcb_statemachine_info_t *statemachine_info)

Address filter — returns true if node should process this message.

◆ handle_outgoing_openlcb_message

bool(* handle_outgoing_openlcb_message) (void)

Try to send the pending outgoing message; returns true if one was pending.

◆ handle_try_reenumerate

bool(* handle_try_reenumerate) (void)

Re-enter the state processor if the enumerate flag is set.

◆ handle_try_pop_next_incoming_openlcb_message

bool(* handle_try_pop_next_incoming_openlcb_message) (void)

Pop next incoming message from the FIFO (thread-safe).

◆ handle_try_enumerate_first_node

bool(* handle_try_enumerate_first_node) (void)

Start enumeration from the first node.

◆ handle_try_enumerate_next_node

bool(* handle_try_enumerate_next_node) (void)

Advance to the next node; frees message when enumeration completes.

◆ snip_simple_node_info_request

void(* snip_simple_node_info_request) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0DE8 — Simple Node Info Request. Optional.

◆ snip_simple_node_info_reply

void(* snip_simple_node_info_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0A08 — Simple Node Info Reply (received). Optional.

◆ event_transport_consumer_identify

void(* event_transport_consumer_identify) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x08F4 — Identify Consumer. Optional.

◆ event_transport_consumer_range_identified

void(* event_transport_consumer_range_identified) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x04A4 — Consumer Range Identified. Optional.

◆ event_transport_consumer_identified_unknown

void(* event_transport_consumer_identified_unknown) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x04C7 — Consumer Identified Unknown. Optional.

◆ event_transport_consumer_identified_set

void(* event_transport_consumer_identified_set) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x04C4 — Consumer Identified Set. Optional.

◆ event_transport_consumer_identified_clear

void(* event_transport_consumer_identified_clear) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x04C5 — Consumer Identified Clear. Optional.

◆ event_transport_consumer_identified_reserved

void(* event_transport_consumer_identified_reserved) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x04C6 — Consumer Identified Reserved. Optional.

◆ event_transport_producer_identify

void(* event_transport_producer_identify) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0914 — Identify Producer. Optional.

◆ event_transport_producer_range_identified

void(* event_transport_producer_range_identified) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0524 — Producer Range Identified. Optional.

◆ event_transport_producer_identified_unknown

void(* event_transport_producer_identified_unknown) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0547 — Producer Identified Unknown. Optional.

◆ event_transport_producer_identified_set

void(* event_transport_producer_identified_set) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0544 — Producer Identified Set. Optional.

◆ event_transport_producer_identified_clear

void(* event_transport_producer_identified_clear) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0545 — Producer Identified Clear. Optional.

◆ event_transport_producer_identified_reserved

void(* event_transport_producer_identified_reserved) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0546 — Producer Identified Reserved. Optional.

◆ event_transport_identify_dest

void(* event_transport_identify_dest) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0968 — Identify Events Addressed. Optional.

◆ event_transport_identify

void(* event_transport_identify) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0970 — Identify Events Global. Optional.

◆ event_transport_learn

void(* event_transport_learn) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0594 — Learn Event. Optional.

◆ event_transport_pc_report

void(* event_transport_pc_report) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x05B4 — PC Event Report. Optional.

◆ event_transport_pc_report_with_payload

void(* event_transport_pc_report_with_payload) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x05F4 — PC Event Report with Payload. Optional.

◆ train_control_command

void(* train_control_command) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x05EB — Train Control Command. Optional.

◆ train_control_reply

void(* train_control_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x01E9 — Train Control Reply (received). Optional.

◆ simple_train_node_ident_info_request

void(* simple_train_node_ident_info_request) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0DA8 — Simple Train Node Ident Info Request. Optional.

◆ simple_train_node_ident_info_reply

void(* simple_train_node_ident_info_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0A48 — Simple Train Node Ident Info Reply (received). Optional.

◆ datagram

void(* datagram) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x1C48 — Datagram. Must reply OK or Rejected. Optional.

◆ datagram_ok_reply

void(* datagram_ok_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0A28 — Datagram Received OK (received). Optional.

◆ load_datagram_rejected

void(* load_datagram_rejected) (openlcb_statemachine_info_t *statemachine_info, uint16_t error_code)

Build Datagram Rejected reply. Optional — called when datagram handler is NULL.

◆ datagram_rejected_reply

void(* datagram_rejected_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0A48 — Datagram Rejected (received). Optional.

◆ stream_initiate_request

void(* stream_initiate_request) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0CC8 — Stream Initiate Request. Optional.

◆ stream_initiate_reply

void(* stream_initiate_reply) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0868 — Stream Initiate Reply (received). Optional.

◆ stream_send_data

void(* stream_send_data) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x1F88 — Stream Data Send. Optional.

◆ stream_data_proceed

void(* stream_data_proceed) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x0888 — Stream Data Proceed (received). Optional.

◆ stream_data_complete

void(* stream_data_complete) (openlcb_statemachine_info_t *statemachine_info)

MTI 0x08A8 — Stream Data Complete (received). Optional.

◆ broadcast_time_event_handler

void(* broadcast_time_event_handler) (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)

Called by the event transport handler for broadcast time Event IDs. Optional.

◆ train_search_event_handler

void(* train_search_event_handler) (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)

Called for train search events; dispatched to every train node. Optional.

◆ train_search_no_match_handler

void(* train_search_no_match_handler) (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)

Called when train search enumeration completes with no match. Optional.

◆ train_emergency_event_handler

void(* train_emergency_event_handler) (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)

Called for well-known emergency events; dispatched to every train node. Optional.


The documentation for this struct was generated from the following file:

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