File syn_bacnet.c¶
FileList > proto > syn_bacnet.c
Go to the source code of this file
Zero-malloc, cleanroom BACnet MS/TP & APDU protocol stack implementation.
#include "syn_bacnet.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_bacnet_add_object (SYN_BACnet_Node * node, uint8_t object_type, uint32_t instance_id, float init_value, const char * name) Register an Object in the BACnet Node database. |
| uint16_t | syn_bacnet_crc16 (const uint8_t * data, size_t len) Calculate BACnet MS/TP Data CRC-16. |
| uint8_t | syn_bacnet_crc8 (const uint8_t * data, size_t len) Calculate BACnet MS/TP Header CRC-8. |
| bool | syn_bacnet_mstp_decode_frame (const uint8_t * buf, size_t len, SYN_BACnet_MSTP_Frame * frame) Decode a raw byte buffer into a BACnet MS/TP Frame structure. |
| size_t | syn_bacnet_mstp_encode_frame (uint8_t frame_type, uint8_t dest_mac, uint8_t src_mac, const uint8_t * payload, uint16_t payload_len, uint8_t * out_buf) Encode a complete BACnet MS/TP Frame. |
| SYN_Status | syn_bacnet_node_init (SYN_BACnet_Node * node, uint8_t mac_address, uint32_t device_id) Initialize a BACnet MS/TP Node context. |
| SYN_Status | syn_bacnet_node_process (SYN_BACnet_Node * node, const SYN_BACnet_MSTP_Frame * rx_frame, SYN_BACnet_MSTP_Frame * tx_frame, bool * has_tx) Process an incoming BACnet MS/TP frame and generate a response if required. |
Public Functions Documentation¶
function syn_bacnet_add_object¶
Register an Object in the BACnet Node database.
SYN_Status syn_bacnet_add_object (
SYN_BACnet_Node * node,
uint8_t object_type,
uint32_t instance_id,
float init_value,
const char * name
)
Parameters:
nodeNode handle.object_typeSYN_BACnet_ObjectType (AI, AO, BI, BO).instance_idInstance ID.init_valueInitial Present Value.nameObject Name string.
Returns:
SYN_OK on success, SYN_ERROR if database full.
function syn_bacnet_crc16¶
Calculate BACnet MS/TP Data CRC-16.
Parameters:
dataData buffer.lenByte count.
Returns:
CRC-16 checksum value.
function syn_bacnet_crc8¶
Calculate BACnet MS/TP Header CRC-8.
Parameters:
dataData buffer.lenByte count.
Returns:
CRC-8 checksum value.
function syn_bacnet_mstp_decode_frame¶
Decode a raw byte buffer into a BACnet MS/TP Frame structure.
bool syn_bacnet_mstp_decode_frame (
const uint8_t * buf,
size_t len,
SYN_BACnet_MSTP_Frame * frame
)
Parameters:
bufInput raw frame byte array.lenInput byte count.frame[out] Decoded MS/TP Frame structure.
Returns:
true if valid MS/TP frame header and CRC-8/CRC-16 match.
function syn_bacnet_mstp_encode_frame¶
Encode a complete BACnet MS/TP Frame.
size_t syn_bacnet_mstp_encode_frame (
uint8_t frame_type,
uint8_t dest_mac,
uint8_t src_mac,
const uint8_t * payload,
uint16_t payload_len,
uint8_t * out_buf
)
Parameters:
frame_typeFrame Type enum.dest_macDestination MAC address.src_macSource MAC address.payloadPayload buffer (can be NULL if payload_len == 0).payload_lenPayload byte count.out_bufDestination output buffer (must be >= payload_len + 10 bytes).
Returns:
Total encoded frame byte count.
function syn_bacnet_node_init¶
Initialize a BACnet MS/TP Node context.
Parameters:
nodeNode handle.mac_addressLocal MAC address (0..127).device_idBACnet Device Instance ID (0..4194302).
Returns:
SYN_OK on success.
function syn_bacnet_node_process¶
Process an incoming BACnet MS/TP frame and generate a response if required.
SYN_Status syn_bacnet_node_process (
SYN_BACnet_Node * node,
const SYN_BACnet_MSTP_Frame * rx_frame,
SYN_BACnet_MSTP_Frame * tx_frame,
bool * has_tx
)
Parameters:
nodeNode context.rx_frameIncoming received frame.tx_frame[out] Outgoing response frame structure.has_tx[out] Set to true if a response frame must be transmitted.
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/proto/syn_bacnet.c