|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Simple Node Information Protocol (SNIP) implementation. More...
Functions | |
| void | ProtocolSnip_initialize (const interface_openlcb_protocol_snip_t *interface_openlcb_protocol_snip) |
| Stores the callback interface. Call once at startup. | |
| uint16_t | ProtocolSnip_load_manufacturer_version_id (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy mfg version byte into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_name (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy manufacturer name string into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_model (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy model string into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_hardware_version (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy hardware version string into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_software_version (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy software version string into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_user_version_id (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Copy user version byte into payload. Returns updated offset. | |
| uint16_t | ProtocolSnip_load_user_name (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Read user name from config memory and copy into payload. | |
| uint16_t | ProtocolSnip_load_user_description (openlcb_node_t *openlcb_node, openlcb_msg_t *outgoing_msg, uint16_t offset, uint16_t requested_bytes) |
| Read user description from config memory and copy into payload. | |
| void | ProtocolSnip_handle_simple_node_info_request (openlcb_statemachine_info_t *statemachine_info) |
| Build and return a SNIP reply (MTI 0x0A08). | |
| void | ProtocolSnip_handle_simple_node_info_reply (openlcb_statemachine_info_t *statemachine_info) |
| Handle incoming SNIP reply — no automatic response generated. | |
| bool | ProtocolSnip_validate_snip_reply (openlcb_msg_t *snip_reply_msg) |
| Validate a SNIP reply: correct MTI, valid length, exactly 6 nulls. | |
Simple Node Information Protocol (SNIP) implementation.
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.
Builds and validates SNIP reply messages from node parameters and config memory. Provides individual field loaders for assembling the SNIP payload and a validation function for incoming SNIP replies.
| void ProtocolSnip_initialize | ( | const interface_openlcb_protocol_snip_t * | interface_openlcb_protocol_snip | ) |
Stores the callback interface. Call once at startup.
Algorithm:
* @param interface_openlcb_protocol_snip Populated callback table. *
| uint16_t ProtocolSnip_load_manufacturer_version_id | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy mfg version byte into payload. Returns updated offset.
Copies manufacturer version ID byte (1 byte).
| uint16_t ProtocolSnip_load_name | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy manufacturer name string into payload. Returns updated offset.
Copies manufacturer name string (null-terminated).
| uint16_t ProtocolSnip_load_model | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy model string into payload. Returns updated offset.
Copies model string (null-terminated).
| uint16_t ProtocolSnip_load_hardware_version | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy hardware version string into payload. Returns updated offset.
Copies hardware version string (null-terminated).
| uint16_t ProtocolSnip_load_software_version | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy software version string into payload. Returns updated offset.
Copies software version string (null-terminated).
| uint16_t ProtocolSnip_load_user_version_id | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copy user version byte into payload. Returns updated offset.
Copies user version ID byte (1 byte).
| uint16_t ProtocolSnip_load_user_name | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Read user name from config memory and copy into payload.
Reads user name from config memory (null-terminated, max 63 bytes).
Algorithm:
* @param openlcb_node Source node. * @param outgoing_msg Destination message. * @param offset Current payload offset. * @param requested_bytes Max bytes to copy. *
| uint16_t ProtocolSnip_load_user_description | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | outgoing_msg, | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Read user description from config memory and copy into payload.
Reads user description from config memory (null-terminated, max 64 bytes).
Algorithm:
* @param openlcb_node Source node. * @param outgoing_msg Destination message. * @param offset Current payload offset. * @param requested_bytes Max bytes to copy. *
| void ProtocolSnip_handle_simple_node_info_request | ( | openlcb_statemachine_info_t * | statemachine_info | ) |
Build and return a SNIP reply (MTI 0x0A08).
Builds a SNIP reply (MTI 0x0A08) from node params + config memory.
Algorithm:
* @param statemachine_info Context with the incoming SNIP request. *
| void ProtocolSnip_handle_simple_node_info_reply | ( | openlcb_statemachine_info_t * | statemachine_info | ) |
Handle incoming SNIP reply — no automatic response generated.
Handles an incoming SNIP reply (MTI 0x0A08). No automatic response.
| bool ProtocolSnip_validate_snip_reply | ( | openlcb_msg_t * | snip_reply_msg | ) |
Validate a SNIP reply: correct MTI, valid length, exactly 6 nulls.
Validates a SNIP reply: correct MTI, valid length, exactly 6 null terminators.
Algorithm:
* @param snip_reply_msg Message to validate. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License