|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Application layer interface for the OpenLCB library. More...
Go to the source code of this file.
Data Structures | |
| struct | interface_openlcb_application_t |
| Application-provided callbacks required by the OpenLCB library. More... | |
Functions | |
| void | OpenLcbApplication_initialize (const interface_openlcb_application_t *interface_openlcb_application) |
| Stores the application callback interface for use by all application layer functions. | |
| void | OpenLcbApplication_clear_consumer_eventids (openlcb_node_t *openlcb_node) |
| Clears the consumer event list for a node by resetting its count to zero. | |
| void | OpenLcbApplication_clear_producer_eventids (openlcb_node_t *openlcb_node) |
| Clears the producer event list for a node by resetting its count to zero. | |
| uint16_t | OpenLcbApplication_register_consumer_eventid (openlcb_node_t *openlcb_node, event_id_t event_id, event_status_enum event_status) |
| Adds a consumer event ID to the node's consumer list. | |
| uint16_t | OpenLcbApplication_register_producer_eventid (openlcb_node_t *openlcb_node, event_id_t event_id, event_status_enum event_status) |
| Adds a producer event ID to the node's producer list. | |
| void | OpenLcbApplication_clear_consumer_ranges (openlcb_node_t *openlcb_node) |
| Clears the consumer event-range list for a node by resetting its range count to zero. | |
| void | OpenLcbApplication_clear_producer_ranges (openlcb_node_t *openlcb_node) |
| Clears the producer event-range list for a node by resetting its range count to zero. | |
| bool | OpenLcbApplication_register_consumer_range (openlcb_node_t *openlcb_node, event_id_t event_id_base, event_range_count_enum range_size) |
| Registers an event ID range in the node's consumer range list. | |
| bool | OpenLcbApplication_register_producer_range (openlcb_node_t *openlcb_node, event_id_t event_id_base, event_range_count_enum range_size) |
| Registers an event ID range in the node's producer range list. | |
| bool | OpenLcbApplication_send_event_pc_report (openlcb_node_t *openlcb_node, event_id_t event_id) |
| Sends a Producer/Consumer Event Report (PCER) message to the network. | |
| bool | OpenLcbApplication_send_event_with_mti (openlcb_node_t *openlcb_node, event_id_t event_id, uint16_t mti) |
| Sends an event message with an arbitrary MTI. | |
| bool | OpenLcbApplication_send_teach_event (openlcb_node_t *openlcb_node, event_id_t event_id) |
| Sends a Learn Event (teach) message to the network. | |
| bool | OpenLcbApplication_send_initialization_event (openlcb_node_t *openlcb_node) |
| Sends an Initialization Complete message for the specified node. | |
| uint16_t | OpenLcbApplication_read_configuration_memory (openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer) |
| Reads bytes from the node's configuration memory via the application callback. | |
| uint16_t | OpenLcbApplication_write_configuration_memory (openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer) |
| Writes bytes to the node's configuration memory via the application callback. | |
Application layer interface for the OpenLCB library.
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.
Application layer interface for the OpenLCB protocol stack. Provides functions for producer/consumer event registration, event transmission, and configuration memory access. Fill in a interface_openlcb_application_t with valid callback pointers and pass it to OpenLcbApplication_initialize() before making any other call in this module.
|
extern |
Stores the application callback interface for use by all application layer functions.
Must be called exactly once during startup, before any other call in this module. The pointed-to structure must remain valid for the lifetime of the program.
| interface_openlcb_application | Pointer to a fully initialised interface_openlcb_application_t. |
Algorithm:
* @param interface_openlcb_application Pointer to a fully initialised interface_openlcb_application_t. *
|
extern |
Clears the consumer event list for a node by resetting its count to zero.
| openlcb_node | Pointer to the openlcb_node_t to clear. |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t to clear. *
|
extern |
Clears the producer event list for a node by resetting its count to zero.
| openlcb_node | Pointer to the openlcb_node_t to clear. |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t to clear. *
|
extern |
Adds a consumer event ID to the node's consumer list.
Stores the event and its initial status at the next available slot in the fixed-size consumer array. Returns the 0-based array index on success so the caller can reference the entry directly later.
| openlcb_node | Pointer to the openlcb_node_t receiving the registration. |
| event_id | 64-bit event_id_t to register (8 bytes, MSB first). |
| event_status | Initial status: one of the event_status_enum values. |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t receiving the registration. * @param event_id 64-bit event_id_t to register (8 bytes, MSB first). * @param event_status Initial status: one of the event_status_enum values. *
|
extern |
Adds a producer event ID to the node's producer list.
Stores the event and its initial status at the next available slot in the fixed-size producer array. Returns the 0-based array index on success so the caller can reference the entry directly later.
| openlcb_node | Pointer to the openlcb_node_t receiving the registration. |
| event_id | 64-bit event_id_t to register (8 bytes, MSB first). |
| event_status | Initial status: one of the event_status_enum values. |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t receiving the registration. * @param event_id 64-bit event_id_t to register (8 bytes, MSB first). * @param event_status Initial status: one of the event_status_enum values. *
|
extern |
Clears the consumer event-range list for a node by resetting its range count to zero.
| openlcb_node | Pointer to the openlcb_node_t to clear. |
Clears the consumer event-range list for a node by resetting its range count to zero.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t to clear. *
|
extern |
Clears the producer event-range list for a node by resetting its range count to zero.
| openlcb_node | Pointer to the openlcb_node_t to clear. |
Clears the producer event-range list for a node by resetting its range count to zero.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t to clear. *
|
extern |
Registers an event ID range in the node's consumer range list.
Stores the base event ID and range size at the next available slot in the fixed-size consumer range array.
| openlcb_node | Pointer to the openlcb_node_t receiving the registration. |
| event_id_base | Base event_id_t of the range. |
| range_size | Number of consecutive event IDs in the range (event_range_count_enum). |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t receiving the registration. * @param event_id_base Base event_id_t of the range. * @param range_size Number of consecutive event IDs (event_range_count_enum). *
|
extern |
Registers an event ID range in the node's producer range list.
Stores the base event ID and range size at the next available slot in the fixed-size producer range array.
| openlcb_node | Pointer to the openlcb_node_t receiving the registration. |
| event_id_base | Base event_id_t of the range. |
| range_size | Number of consecutive event IDs in the range (event_range_count_enum). |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t receiving the registration. * @param event_id_base Base event_id_t of the range. * @param range_size Number of consecutive event IDs (event_range_count_enum). *
|
extern |
Sends a Producer/Consumer Event Report (PCER) message to the network.
Builds a global PCER message (MTI 0x05B4) with the given event ID and queues it via the send_openlcb_msg callback. Returns immediately; actual transmission happens when the transport layer drains its queue.
| openlcb_node | Pointer to the sending openlcb_node_t. |
| event_id | 64-bit event_id_t to report. |
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param event_id 64-bit event_id_t to report. *
|
extern |
Sends an event message with an arbitrary MTI.
Builds a global OpenLCB message carrying the given event ID and MTI, then queues it via the send_openlcb_msg callback. Useful for sending event MTIs that do not have a dedicated helper function.
| openlcb_node | Pointer to the sending openlcb_node_t. |
| event_id | 64-bit event_id_t to include in the payload. |
| mti | 16-bit MTI value for the message. |
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param event_id 64-bit event_id_t to include in the payload. * @param mti 16-bit MTI for the message. *
|
extern |
Sends a Learn Event (teach) message to the network.
Builds a global Learn Event message (MTI 0x0594) with the given event ID and queues it via the send_openlcb_msg callback. Used during teach/learn configuration to inform other nodes of a new event association.
| openlcb_node | Pointer to the sending openlcb_node_t. |
| event_id | 64-bit event_id_t to teach. |
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param event_id 64-bit event_id_t to teach. *
|
extern |
Sends an Initialization Complete message for the specified node.
Builds a global Initialization Complete message (MTI 0x0100) whose 6-byte payload carries the node's full 48-bit Node ID, then queues it via the send_openlcb_msg callback. Per the OpenLCB Message Network Standard this message must be sent after alias negotiation completes and before any other OpenLCB messages.
| openlcb_node | Pointer to the openlcb_node_t that has just finished login. |
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t that has just finished login. *
|
extern |
Reads bytes from the node's configuration memory via the application callback.
Passes the request through to the config_memory_read callback. Returns 0xFFFF immediately if the callback pointer is NULL.
| openlcb_node | Pointer to the requesting openlcb_node_t. |
| address | Starting address within the configuration address space. |
| count | Number of bytes to read. |
| buffer | Destination configuration_memory_buffer_t. |
Algorithm:
* @param openlcb_node Pointer to the requesting openlcb_node_t. * @param address Starting address within the configuration address space. * @param count Number of bytes to read. * @param buffer Destination configuration_memory_buffer_t. *
|
extern |
Writes bytes to the node's configuration memory via the application callback.
Passes the request through to the config_memory_write callback. Returns 0xFFFF immediately if the callback pointer is NULL.
| openlcb_node | Pointer to the requesting openlcb_node_t. |
| address | Starting address within the configuration address space. |
| count | Number of bytes to write. |
| buffer | Source configuration_memory_buffer_t. |
Algorithm:
* @param openlcb_node Pointer to the requesting openlcb_node_t. * @param address Starting address within the configuration address space. * @param count Number of bytes to write. * @param buffer Source configuration_memory_buffer_t. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License