Miscellaneous
Debugging and Diagnostics
-
void osdp_logger_init(const char *name, int log_level, osdp_log_puts_fn_t puts_fn)
Configure OSDP Logging.
Note: This function has to be called before osdp_{cp,pd}_setup(). Otherwise it will be ignored.
- Parameters:
name – A soft name for this module; will appear in all the log lines.
log_level – OSDP log levels of type
enum osdp_log_level_e
. Default is LOG_INFO.puts_fn – A 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.
-
const char *osdp_get_version()
Get LibOSDP version as a
const char *
. Used in diagnostics.- Return values:
version – string
-
const 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.- Return values:
source – identifier string
Status
File Operations
-
struct osdp_file_ops
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.
Public Members
-
void *arg
A opaque pointer to private data that can be filled by the application which will be passed as the first argument for each of the below functions. Applications can keep their file context info such as the open file descriptors or any other private data here.
-
osdp_file_open_fn_t open
open handler function
-
osdp_file_read_fn_t read
read handler function
-
osdp_file_write_fn_t write
write handler function
-
osdp_file_close_fn_t close
close handler function
-
void *arg
-
int 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.
- Parameters:
ctx – OSDP context
pd – PD number in case of CP. This param is ignored in PD mode
ops – Populated file operations struct
- Return values:
0 – on success. -1 on errors.
-
int osdp_get_file_tx_status(const osdp_t *ctx, int pd, int *size, int *offset)
Query file transfer status if one is in progress. Calling this method when there is no file transfer progressing will return error.
- Parameters:
ctx – OSDP context
pd – PD number in case of CP. This param is ignored in PD mode
size – Total size of the file (as obtained from file_ops->open())
offset – Offset into the file that has been sent/received (CP/PD)
- Return values:
0 – on success. -1 on errors.