|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
OpenLCB node allocation, enumeration, and lifecycle management. More...
Go to the source code of this file.
Data Structures | |
| struct | interface_openlcb_node_t |
| Dependency injection interface for the OpenLCB Node module. More... | |
Functions | |
| void | OpenLcbNode_initialize (const interface_openlcb_node_t *interface) |
| Initializes the node management module. | |
| openlcb_node_t * | OpenLcbNode_allocate (uint64_t node_id, const node_parameters_t *node_parameters) |
| Allocates a new node with the given ID and configuration. | |
| openlcb_node_t * | OpenLcbNode_get_first (uint8_t key) |
| Returns the first allocated node for enumeration. | |
| openlcb_node_t * | OpenLcbNode_get_next (uint8_t key) |
| Returns the next allocated node for the given enumerator key. | |
| bool | OpenLcbNode_is_last (uint8_t key) |
| Returns true if the current enumeration position is the last node. | |
| openlcb_node_t * | OpenLcbNode_find_by_alias (uint16_t alias) |
| Finds a node by its 12-bit CAN alias. | |
| openlcb_node_t * | OpenLcbNode_find_by_node_id (uint64_t node_id) |
| Finds a node by its 64-bit OpenLCB node ID. | |
| void | OpenLcbNode_reset_state (void) |
| Resets all allocated nodes to their initial login state. | |
| uint16_t | OpenLcbNode_get_count (void) |
| Returns the number of allocated nodes. | |
| void | OpenLcbNode_100ms_timer_tick (uint8_t current_tick) |
| 100ms timer tick handler — gates the application callback. | |
OpenLCB node allocation, enumeration, and lifecycle management.
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.
Manages a fixed-size pool of openlcb_node_t structures. Supports allocation with auto-generated event IDs, multiple simultaneous enumerators for iterating through allocated nodes, and lookup by CAN alias or 64-bit node ID. Must be initialized before any node operations.
|
extern |
Initializes the node management module.
Clears all node structures, resets the node count, and stores the optional callback interface. Must be called once at startup before any other OpenLcbNode function.
| interface | Pointer to interface_openlcb_node_t with optional callbacks, or NULL. |
Algorithm:
* @param interface Pointer to @ref interface_openlcb_node_t with optional callbacks, or NULL *
|
extern |
Allocates a new node with the given ID and configuration.
Finds the first free slot in the pool, initializes it with the provided node ID, stores the configuration pointer (not copied), and auto-generates event IDs. Returns NULL if the pool is full.
| node_id | 64-bit unique OpenLCB node identifier. |
| node_parameters | Pointer to node_parameters_t defining node capabilities. |
Algorithm:
* @param node_id 64-bit unique OpenLCB node identifier * @param node_parameters Pointer to @ref node_parameters_t defining node capabilities *
|
extern |
Returns the first allocated node for enumeration.
Resets the enumeration index for the given key and returns the first node. Multiple independent enumerators are supported using different key values (0 to MAX_NODE_ENUM_KEY_VALUES - 1).
| key | Enumerator index (0 to MAX_NODE_ENUM_KEY_VALUES - 1). |
Algorithm:
* @param key Enumerator index (0 to MAX_NODE_ENUM_KEY_VALUES - 1) *
|
extern |
Returns the next allocated node for the given enumerator key.
| key | Same enumerator index used in the corresponding get_first call. |
Algorithm:
* @param key Same enumerator index used in the corresponding get_first call *
|
extern |
Returns true if the current enumeration position is the last node.
| key | Same enumerator index used in the corresponding get_first/get_next calls. |
Algorithm:
* @param key Same enumerator index used in the corresponding get_first/get_next calls *
|
extern |
Finds a node by its 12-bit CAN alias.
| alias | 12-bit CAN alias to search for. |
Algorithm:
* @param alias 12-bit CAN alias to search for *
|
extern |
Finds a node by its 64-bit OpenLCB node ID.
| node_id | 64-bit OpenLCB node identifier to search for. |
Algorithm:
* @param node_id 64-bit OpenLCB node identifier to search for *
|
extern |
Resets all allocated nodes to their initial login state.
Sets run_state to RUNSTATE_INIT and clears permitted and initialized flags. Does not deallocate nodes or clear configuration.
Algorithm:
|
extern |
Returns the number of allocated nodes.
|
extern |
100ms timer tick handler — gates the application callback.
Called from the main loop with the current global tick. Fires the application callback at most once per unique tick value.
| current_tick | Current value of the global 100ms tick counter. |
Called from the main loop with the current global tick. Fires the application callback at most once per unique tick value. The per-node timerticks increment has been removed — all modules now use the global clock via subtraction-based elapsed-time checks.
* @param current_tick Current value of the global 100ms tick counter. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License