Documentation
Miscellaneous
Debugging and Diagnostics
For how to configure the logger and capture packet/data traces, see the Debugging guide.
Different levels of log messages; based on importance of the message with LOG_EMERG being most critical to LOG_DEBUG being the least.
OSDP_LOG_EMERGOSDP_LOG_ALERTOSDP_LOG_CRITOSDP_LOG_ERROROSDP_LOG_WARNINGOSDP_LOG_NOTICEOSDP_LOG_INFOOSDP_LOG_DEBUGOSDP_LOG_MAX_LEVELvoid osdp_logger_init(const char *name, int log_level, osdp_log_puts_fn_t puts_fn)Configure OSDP Logging.
nameA soft name for this module; will appear in all the log lines.log_levelOSDP log levels of type enum osdp_log_level_e. Default is LOG_INFO.puts_fnA puts() like function that will be invoked to write the log buffer. Can be handy if you want to log to file on a UART device without putchar redirection. See osdp_log_puts_fn_t definition to see the behavioral expectations. When this is set to NULL, LibOSDP will log to stderr.The logger can route output either through a simple puts-style sink or a richer structured callback.
typedef int(* osdp_log_puts_fn_t) (const char *msg)Puts a string to the logging medium.
msga null-terminated char buffer.0on success; -ve on errorstypedef void(* osdp_log_callback_fn_t) (int pd, int log_level, const char *msg, const char *file, unsigned long line)A callback function to be used with external loggers.
pdAddress of PD associated with this message; -1 for non-PD/system logslog_levelA syslog style log level. See enum osdp_log_level_emsgThe log messagefileRelative path to file which produced the log messagelineLine number in file which produced the log messagevoid osdp_set_log_callback(osdp_log_callback_fn_t cb)Set logging callback for LibOSDP.
cbThe callback function. See osdp_log_callback_fn_t for more details.const char * osdp_get_version()Get LibOSDP version as a const char *. Used in diagnostics.
versionstringconst char * osdp_get_source_info()Get LibOSDP source identifier as a const char *. This string has info about the source tree from which this version of LibOSDP was built. Used in diagnostics.
sourceidentifier stringStatus and Metrics
void osdp_get_status_mask(const osdp_t *ctx, uint8_t *bitmask)Get a bit mask of number of PD that are online currently.
ctxOSDP contextbitmaskpointer to an array of bytes. must be as large as (num_pds + 7 / 8).void osdp_get_sc_status_mask(const osdp_t *ctx, uint8_t *bitmask)Get a bit mask of number of PD that are online and have an active secure channel currently.
ctxOSDP contextbitmaskpointer to an array of bytes. must be as large as (num_pds + 7 / 8).Link/protocol health counters accumulated since the last osdp_get_metrics() call.
uint32_t packets_sentuint32_t packets_receiveduint32_t packet_check_errorsuint32_t nak_countuint32_t sc_handshake_countuint32_t sc_failure_countuint32_t command_countuint32_t event_countint osdp_get_metrics(osdp_t *ctx, int pd_idx, struct osdp_metrics *out)Read and reset link/protocol health counters for one PD slot.
ctxOSDP contextpd_idxPD index to snapshot (0..NUM_PD-1)outDestination struct filled with the current counter values. The counters for this PD are then cleared to zero.0on success, -1 on invalid arguments.File Operations
Register a set of file callbacks so LibOSDP can drive an OSDP file transfer against storage your application controls.
typedef int(* osdp_file_open_fn_t) (void *arg, int file_id, uint32_t *size)Open a pre-agreed file.
argOpaque pointer that was provided in osdp_file_ops when the ops struct was registered.file_idFile ID of pre-agreed file between this CP and PDsizeSize of the file that was opened (to be populated by sender). In case of receiver, this value is just just input to indicate the incoming file size.0on success-1on errorstypedef int(* osdp_file_read_fn_t) (void *arg, void *buf, uint32_t size, uint32_t offset)Read a chunk of file data into buffer.
argOpaque pointer that was provided in osdp_file_ops when the ops struct was registered.bufBuffer to store file data readsizeNumber of bytes to read from file into bufferoffsetNumber of bytes from the beginning of the file to start reading from.Numberof bytes read0on EOF-veon errors.typedef int(* osdp_file_write_fn_t) (void *arg, const void *buf, uint32_t size, uint32_t offset)Write a chunk of file data from buffer to disk.
argOpaque pointer that was provided in osdp_file_ops when the ops struct was registered.bufBuffer with file data to be stored to disksizeNumber of bytes to write to diskoffsetNumber of bytes from the beginning of the file to start writing too.Numberof bytes written0on EOF-veon errors.typedef int(* osdp_file_close_fn_t) (void *arg)Close file that corresponds to a given file descriptor.
argOpaque pointer that was provided in osdp_file_ops when the ops struct was registered.0on success-1on errors.OSDP File operations struct that needs to be filled by the CP/PD application and registered with LibOSDP using osdp_file_register_ops() before a file transfer command can be initiated.
void * argosdp_file_open_fn_t openosdp_file_read_fn_t readosdp_file_write_fn_t writeosdp_file_close_fn_t closeint osdp_file_register_ops(osdp_t *ctx, int pd, const struct osdp_file_ops *ops)Register a global file operations struct with OSDP. Both CP and PD modes should have done so already before CP can sending a OSDP_CMD_FILE_TX.
ctxOSDP contextpdPD number in case of CP. This param is ignored in PD modeopsPopulated file operations struct0on success. -1 on errors.enum::osdp_file_tx_outcomeint osdp_get_file_tx_status(const osdp_t *ctx, int pd, uint32_t *size, uint32_t *offset)Query file transfer status if one is in progress. Calling this method when there is no file transfer progressing will return error.
ctxOSDP contextpdPD number in case of CP. This param is ignored in PD modesizeTotal size of the file (as obtained from file_ops->open())offsetOffset into the file that has been sent/received (CP/PD)0on success. -1 on errors.