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

Train Search Protocol message handler. More...

Go to the source code of this file.

Data Structures

struct  interface_protocol_train_search_handler_t
 Application callbacks for train search events. More...
 

Functions

void ProtocolTrainSearch_initialize (const interface_protocol_train_search_handler_t *interface)
 Initializes the Train Search Protocol handler.
 
void ProtocolTrainSearch_handle_search_event (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Handles incoming train search events.
 
void ProtocolTrainSearch_handle_search_no_match (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id)
 Handles the no-match case after full train search enumeration.
 

Detailed Description

Train Search Protocol message handler.

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.

Handles incoming train search Event IDs from the network. Decodes the search query (DCC address, flags) and compares against each train node's address. Matching nodes reply with a Producer Identified event containing their own address.

Called from the main statemachine when a train search event is detected. Unlike broadcast time (node index 0 only), train search is called for every train node so each can check for a match.

Author
Jim Kueneman
Date
28 Feb 2026
See also
openlcb_application_train.h - Train state with DCC address
openlcb_utilities.h - Event ID encoding/decoding functions

Function Documentation

◆ ProtocolTrainSearch_initialize()

void ProtocolTrainSearch_initialize ( const interface_protocol_train_search_handler_t * interface)
extern

Initializes the Train Search Protocol handler.

Parameters
interfacePointer to interface_protocol_train_search_handler_t callbacks (may be NULL).

Initializes the Train Search Protocol handler.

* @param interface  Populated callback table (may be NULL).
* 

◆ ProtocolTrainSearch_handle_search_event()

void ProtocolTrainSearch_handle_search_event ( openlcb_statemachine_info_t * statemachine_info,
event_id_t event_id )
extern

Handles incoming train search events.

Called from the main statemachine MTI_PC_EVENT_REPORT case for each train node. Decodes the search query, compares against this node's DCC address, and if matching, loads a Producer Identified reply.

Parameters
statemachine_infoPointer to openlcb_statemachine_info_t context.
event_idFull 64-bit event_id_t containing encoded search query.

Decodes the search query, compares against this node's DCC address, and loads a Producer Identified reply if matched.

* @param statemachine_info  Pointer to openlcb_statemachine_info_t context.
* @param event_id           Full 64-bit event_id_t containing encoded search query.
* 

◆ ProtocolTrainSearch_handle_search_no_match()

void ProtocolTrainSearch_handle_search_no_match ( openlcb_statemachine_info_t * statemachine_info,
event_id_t event_id )
extern

Handles the no-match case after full train search enumeration.

If the ALLOCATE flag is set and on_search_no_match is registered, invokes the callback to create a new virtual train node.

Parameters
statemachine_infoPointer to openlcb_statemachine_info_t context.
event_idFull 64-bit event_id_t containing encoded search query.

Handles the no-match case after full train search enumeration.

Called by the main statemachine when the last node in the enumeration has been reached and no train node matched the search query. If the ALLOCATE flag is set in the search event and the on_search_no_match callback is registered, invokes it so the application can create a new virtual train node.

* @param statemachine_info  Pointer to openlcb_statemachine_info_t context.
* @param event_id           Full 64-bit event_id_t containing encoded search query.
* 

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